setTranslatesAutoresizingMaskIntoConstraints:无法调用非函数类型Bool的值

时间:2018-06-05 23:16:34

标签: ios swift

我有以下代码:

let button = UIButton(type: .system) as UIButton
button.setTitle(title, for: .normal)
button.setTranslatesAutoresizingMaskIntoConstraints(false)

但是Xcode(9.4)抱怨

  

'UIButton'类型的值没有成员'setTranslatesAutoresizingMaskIntoConstraints'

1 个答案:

答案 0 :(得分:0)

对于Swift4(Xcode 9.4),必须将其更改为以下内容:

button.translatesAutoresizingMaskIntoConstraints = false