1/**2* 使用Custom UIView的这条路,我走的很不顺利,前期犯2,中期有事,浪费了很多时间!3* 现在空闲的时间不多了,只能抓紧时间写两个小demo,一来做练习,二来整理下也许能给要学习的人一些帮助!4*/
1/**2* Custom UIView常用的三种实现方法:3* Method_1:通过初始化的方式(eg:UITableViewCell的重写)4Method_2:通过drawRect的方法,使用代码自己画出想要的视图5Method_3:通过xib6*/
/**
* 初始化代码:
*
* @return [nibView objectAtIndex:0]*/+ (ZYCustomView *)initCustomView
{
NSArray* nibView = [[NSBundle mainBundle] loadNibNamed:@"ZYCustomView"owner:nil options:nil];return[nibView objectAtIndex:0];
}
/**
* 在ViewController里引用*/- (void)viewDidLoad
{
[super viewDidLoad];//Do any additional setup after loading the view, typically from a nib.ZYCustomView*test =[ZYCustomView initCustomView];
test.backgroundColor=[UIColor yellowColor];
test.clipsToBounds=YES;
test.frame= CGRectMake(0,20,320,200);
test.lb1.text=@"我是第一行";
[self.view addSubview:test];
}