【发布时间】:2019-12-13 09:01:12
【问题描述】:
制作一个具有固定高度约束的 UIView,注意我在 IB 中将其设置为 40。
将约束类改成这样:
@IBDesignable class BadassHeightConstraint: NSLayoutConstraint {
override var constant: CGFloat {
set {
super.constant = newValue
}
get {
return calc()
}
}
private func calc() -> CGFloat {
return 100.0
}
}
这在运行时完美运行,左图是 100,而不是 40。
但是,我无法让它在 IB 中工作。为什么会这样?
有什么解决方案可以在 IB 中进行这些工作吗?
【问题讨论】:
标签: ios interface-builder nslayoutconstraint ibdesignable