【发布时间】:2015-12-14 09:14:29
【问题描述】:
我有一个 IBDesignable 类。
@IBDesignable
class Foobar: UIView {
// ignore all init code
var foo: CGFloat = 12
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
// use property foo to draw something
}
}
让我奇怪的是,当drawRect调用时,foo是0,所以XCode中显示的视图是错误的。我可以在prepareForInterfaceBuilder() 中为foo 赋值来解决这个问题。我不知道是什么导致了这个问题。
【问题讨论】:
标签: swift ibdesignable