I have a custom view with an image in it. And i get an error when the interface builder try's to render the Custom view.
I have 6 of these views and i get 3 different errors.
Failed to update auto layout status: interface builder cocoa touch tool crashed.
Failed to render instance of CustomView: Rendering the view took longer than 200 ms. Your drawing code may suffer from sloe performance.
Failed to render instance of CustomView: the designable agent crashed.
And when i debug the view it crashes on the UIimage propriety. and i get an error:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
How can i fix this?
Thanks
CODE:
@IBDesignable
class UIProgressButton: UIAnimatedButton {
//it crashed here
@IBInspectable
var icon: UIImage = UIImage(named: "feet")!{
didSet {
setupView()
}
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
let iconLayer = CALayer()
func setupView(){
iconLayer.frame = CGRectMake(0, 5, self.frame.height-10, self.frame.height-10)
iconLayer.contents = self.icon.CGImage
self.layer.addSublayer(iconLayer)
}
}