2

The IBDesignable property seems to be not working on Xcode 7 using swift 2. Below is my custom class to draw a button.

@IBDesignable class PushButtonView: UIButton {

override func drawRect(rect: CGRect) {
    let path = UIBezierPath(ovalInRect: rect)
    UIColor.greenColor().setFill()
    path.fill()
}

the code is running in the simulator. (See image 1) I have also attached a screenshot of the storyboard (see image 2) Not sure if some settings need to be changed

enter image description here enter image description here

Anuj Arora
  • 3,017
  • 3
  • 29
  • 43
  • Your code is work fine for me using beta 6. I see the green button as expected in the storyboard. Does the project build okay? – simons Aug 29 '15 at 11:23
  • builds okay..but it doesnt show in the storyboard which is a pain...need to always run the code to see if things are fine..and this is just the beginning of graphics..will be using lot more – Anuj Arora Aug 29 '15 at 11:31
  • Possible duplicate of [IB_DESIGNABLE, IBInspectable -- Interface builder does not update](http://stackoverflow.com/questions/26674111/ib-designable-ibinspectable-interface-builder-does-not-update) but there aren't enough details here to say this is definitely the case. Either way, I'd take a gander over there. – nhgrif Aug 29 '15 at 12:19
  • Thanks this works..can't say yes to correct answer for SO badges as it is in the comment..but thanks again – Anuj Arora Aug 29 '15 at 12:54
  • @AnujArora Having a similar problem. Which "this works" worked? Can you post the complete solution you found in the answer section, please? – Sean Dec 14 '15 at 02:48

2 Answers2

2

I had the same issue with "Mixpanel" CocoaPod.

You can check if everything is compiling for the interface builder in the Report Navigator (Left pane, the right-most tab). Click on "By Group" to filter content and look at the "Interface Builder" section. You will see there if something went wrong while compiling with the ibtool. In my case mixpanel survey widget was not compiling.

I simply removed the pod from the podfile, did pod install and could work on my custom view. Once done with the custom view i added mixpanel to the podfile again. Hope this helps

Martin Mlostek
  • 2,755
  • 1
  • 28
  • 57
0

Click Editor > Refresh All Views after you make the changes.

enter image description here

Alternatively, you can also select Editor > Automatically Refresh Views, but I find that sometimes buggy and may not consistently.

Yuchen
  • 30,852
  • 26
  • 164
  • 234