简体   繁体   中英

How do I add custom UIButton to nib file in XCode?

I've just begin delving in to the world of iOS development. I am also a newbie to XCode. I've built several little test apps nows using the default UIComponents available by dragging and dropping them from the Objects library on to my .xib file and hooking up outlets and actions just to see how it all works. I wanted to take it to the next step and create my own custom painted button. I have a class named CustomButton that extends UIButton and I can programmatically add it to a view, but I would like to know how to drag and drop it on to a nib file so I can lay it out visually rather than programmatically. I know this is a beginner question but I've searched all night trying to find an example of how to do it with no success. Any help is greatly appreciated.

Drop in a UIView into your nib and set its Custom Class to your UIButton subclass.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM