2

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) {
        // ...
    }
}
henrikstroem
  • 2,978
  • 4
  • 35
  • 51
  • Check this: https://stackoverflow.com/questions/26674111/ib-designable-ibinspectable-interface-builder-does-not-update?rq=1 – uraimo Nov 05 '15 at 15:00
  • @uraimo I saw this before posting my question, but my Xcode was already auto updating. – henrikstroem Nov 05 '15 at 15:16

1 Answers1

3

I think it is safe to say "It is @IBDesignable Bug in Xcode 7.1.1"

Because:

  1. Running project does show the CGAffineTransform with the given rotation.
  2. If borderWidth, borderColor etc. are changed in this didSet block, it shows in the Storyboard correctly.
  3. I could not find anything in the apple developer site that says transformation will not work for @IBDesignable
Warif Akhand Rishi
  • 23,920
  • 8
  • 80
  • 107