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

本小妞迷上赌 提交于 2020-01-05 05:57:17

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/5400493/how-do-i-add-custom-uibutton-to-nib-file-in-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!