如何在XCode的nib文件中添加自定义UIButton? [英] How do I add custom UIButton to nib file in XCode?

查看:364
本文介绍了如何在XCode的nib文件中添加自定义UIButton?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始深入研究iOS开发领域.我也是XCode的新手.现在,我已经使用可用的默认UIComponent构建了一些小测试应用程序,方法是将它们从Objects库拖放​​到.xib文件中,并连接插座和操作,以查看其工作原理.我想将其用于下一步,并创建自己的自定义绘制按钮.我有一个名为CustomButton的类,该类扩展了UIButton,可以以编程方式将其添加到视图中,但是我想知道如何将其拖放到nib文件中,以便可以以可视方式而不是以编程方式对其进行布局.我知道这是一个初学者的问题,但是我整夜都在搜寻以寻找一个成功的例子.任何帮助是极大的赞赏.

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.

推荐答案

将UIView放到笔尖中,并将其自定义类"设置为UIButton子类.

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

这篇关于如何在XCode的nib文件中添加自定义UIButton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆