大佬教程收集整理的这篇文章主要介绍了ios – 如何在Interface Builder中使用自定义UIButton?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@implementation BlaButtonVC - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { NSArray *subViews = [[NSBundle mainBundle] loadNibNamed:@"BlaButton" owner:self options:nil]; [self addSubview:subViews[0]]; } return self; } @end
我可以将此按钮添加到视图中,如下所示:
// ViewController.m BlaButtonVC *button = [[BlaButtonVC alloc] initWithFrame:CGRectMake(10,10,280,44)]; button.titleXLabel.text = @"Nyuff"; button.descLabel.text = @"Kukk"; [self.view addSubview:button];
我的问题是我不知道如何从Interface Bulder这样做,如何使用这个UIButton子类而不是正常的子类.
已将Button Type更改为Custom,将Custom Class更改为BlaButtonVC,但这还不够.它将调用BlaButtonVC initWithFrame,但按钮不会出现在Interface Builder中,也不会出现在Simulator中.
我错过了什么?
在这里您可以找到完整的样本:
https://www.dropbox.com/s/ioucpb6jn6nr0hs/blabla1.zip
以上是大佬教程为你收集整理的ios – 如何在Interface Builder中使用自定义UIButton?全部内容,希望文章能够帮你解决ios – 如何在Interface Builder中使用自定义UIButton?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。