How to make an IBDesignable component that has an angle: CGFloat property that rotates the view
import UIKit
@IBDesignable
class MyB: UIButton {
@IBInspectable
var angle: CGFloat = 0 {
didSet {
//What to put here?
}
}
override init(frame: CGRect) {
super.init(frame: frame)
// Initialization code
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
I tried
self.transform = CGAffineTransformMakeRotation(angle)
but it doesn't work