简体   繁体   English

如何在XCode的nib文件中添加自定义UIButton?

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

I've just begin delving in to the world of iOS development. 我刚刚开始深入研究iOS开发领域。 I am also a newbie to XCode. 我也是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. 现在,我已经使用可用的默认UIComponent构建了一些小测试应用程序,方法是将它们从Objects库拖放​​到.xib文件中,并连接插座和操作,以查看其工作原理。 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. 我有一个名为CustomButton的类,该类扩展了UIButton,可以以编程方式将其添加到视图中,但是我想知道如何将其拖放到nib文件中,以便可以以可视方式而不是以编程方式对其进行布局。 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. 将UIView放入笔尖,并将其自定义类设置为UIButton子类。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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