【发布时间】:2013-08-02 09:37:00
【问题描述】:
我想创建一个非常简单的 customView,上面有几个 UIlabel,我应该怎么做。任何教程或建议将不胜感激。我是新手,之前没试过。
我用 xib 试过这个。
@interface MyCustomView : UIView
@property (strong, nonatomic) IBOutlet UILabel *Label;
@end
实施
#import "MyCustomTimer.h"
@implementation MyCustomView
-(id)initWithCoder:(NSCoder *)aDecoder{
if ((self = [super initWithCoder:aDecoder])){
[self addSubview:[[[NSBundle mainBundle] loadNibNamed:@"MyCustomView" owner:self options:nil] objectAtIndex:0]];
}
return self;
}
@end
但我需要以编程方式进行,请帮助。谢谢
【问题讨论】:
-
这个问题对于一个简单的 QA 问题来说太宽泛了。浏览上面的书,它以编程方式涵盖了所有内容。
-
@Ezimettekin 你想在已经存在的类中创建一个自定义视图或者你想用 nib 文件创建一个 UIView 类
标签: iphone ios ios6 custom-view