问题
My custom button below works fine on the iOS Simulator - when I set a rotation in Interface Builder it rotates the button when I run the app.
However, I can't see the rotation in the Story Board - it just shows the button without applying the transformation.
It doesn't matter if I do the transformation inside the drawRect
method - same result.
import Foundation
import UIKit
@IBDesignable class CustomButton: UIButton {
@IBInspectable var rotation: CGFloat = 0.0 {
didSet {
self.transform = CGAffineTransformMakeRotation(CGFloat(rotation))
}
}
override func drawRect(rect: CGRect) {
// ...
}
}
回答1:
I think it is safe to say "It is @IBDesignable
Bug in Xcode 7.1.1
"
Because:
- Running project does show the
CGAffineTransform
with the given rotation. - If
borderWidth
,borderColor
etc. are changed in thisdidSet
block, it shows in theStoryboard
correctly. - I could not find anything in the apple developer site that says transformation will not work for
@IBDesignable
来源:https://stackoverflow.com/questions/33545455/ibinspectable-not-updating-story-board