如何执行通用的.appearance()。setValue(UIColor.red,forKey:“ color”)调用?

时间:2019-03-04 02:31:12

标签: swift

是否可以通过.appearance()上的setValue设置通用属性?

例如

@IBDesignable class Button: UIView {
    @IBInspectable dynamic var color: UIColor? = .blue
}

let button = Button()
let app = type(of: button).appearance()

// works
print(app.color)

// crashes
app.setValue(UIColor.blue, forKey: "color")

0 个答案:

没有答案