关于Swift中的隐式成员表达式,我遇到了一些不一致的行为:
import UIKit
let button = UIButton()
button.backgroundColor = .brownColor() # works
button.setTitleColor(.brownColor(), forState: .Normal) # doesn't work
button.setTitleColor(UIColor.brownColor(), forState: .Normal) # works
在作业中使用前导点表示法时,所有工作都按预期工作。当使用它作为函数的参数时,swift 会抛出编译器错误(操场崩溃)。为了使情况复杂化,UIControlState
枚举正确地插入了隐式成员表达式值。
这是一个错误吗?