Search code examples
cocoa-touchxcodeios4buttoninterface-builder

Create custom buttons for Interface Builder


Does anyone know how to create custom buttons for Interface Builder? Like instead of have just a regular Round Rect Button, I want to have like a custom 3D button and some random image background for that button. How to do this?


Solution

  • You will either need to find a third-party class (ideally with an Interface Builder plug-in so you can see it live in the IB file) or subclass UIButton or NSButton/NSButtonCell for Mac and provide your own 3D rainbow unicorn drawing behavior. :-)

    Interface Builder can only show you classes it knows about - you can't add behavior / modify existing drawing behavior there because that's the wrong tool for the job. You'll need to find someone else's or subclass your own in code then let IB know about it.

    Update based on OP's comment

    You can use -setImage:forState: to supply your custom image for the given states.