Я создаю подкласс UIButton для добавления некоторого рисунка. Он отлично работает в коде. Он дает следующую ошибку, когда я пытаюсь через @IBdesignable.CGContextRef не работает с @IBDesignable (Ошибка: агент разбился)
ошибка: IB Designables: Не удалось обновить статус Автокомпоновка: агент разбился
ошибка: IB Designables: Не удалось отобразить экземпляр DashboardHeaderView: Агент разбился
Ниже приводится пример кода
let context:CGContextRef = UIGraphicsGetCurrentContext()!
UIGraphicsPushContext(context)
UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0);
var path:UIBezierPath!
let pathRect:CGRect = CGRectMake(strokeWidth/2, strokeWidth/2, pathSize - iconStrokeWidth, pathSize - iconStrokeWidth);
path = UIBezierPath(rect: pathRect)
iconColor.setStroke()
iconPath.lineWidth = iconStrokeWidth;
iconPath.stroke()
CGContextAddPath(context, iconPath.CGPath);
let image:UIImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsPopContext();
UIGraphicsEndImageContext();
ошибка сбой
агента в
let context:CGContextRef = UIGraphicsGetCurrentContext()!
Я overirde инициализации + DrawRect + initilizeButtonDrawings, но не получил ничего положительного
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
self.initilizeButtonDrawings()
}
override init(frame: CGRect) {
super.init(frame: frame)
self.initilizeButtonDrawings()
}
override func drawRect(rect:CGRect) {
super.drawRect(rect)
self.initilizeButtonDrawings()
}
override func prepareForInterfaceBuilder() {
self.initilizeButtonDrawings()
}
Все это работает отлично с Objective C но сбой в быстрой