Tru*_*an1 5 xcode ios autolayout nslayoutconstraint xcode7
我是子类NSLayoutConstraint,根据标志提供自定义间距.是否有可能在Interface Builder中反映出来?我尝试使用IBDesignable和prepareForInterfaceBuilder,但它对NSLayoutConstraintInterface Builder 没有任何影响(仅在运行时它反映).
这是我正在尝试的:
@IBDesignable
class CustomLayoutConstraint: NSLayoutConstraint {
@IBInspectable var doubleConstant: Bool = false
override func awakeFromNib() {
super.awakeFromNib()
handleSelection()
}
override func prepareForInterfaceBuilder() {
handleSelection()
}
func handleSelection() {
if doubleConstant {
constant *= 2
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个标志,IBInspectable如果设置,将在运行时将常量加倍.有没有办法在StoryBoard中反映这一点,所以很明显会发生什么事情?
| 归档时间: |
|
| 查看次数: |
285 次 |
| 最近记录: |