我有一个 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调用foois时0,XCode 中显示的视图是错误的。foo我可以给in赋值prepareForInterfaceBuilder()来解决这个问题。我不知道是什么导致了这个问题。