标签:
1 Button 手写代码生产的方式
-(void)viewDidLoad { [super viewDidLoad]; UIButton *btn = [[UIButton alloc]init]; btn.frame = CGRectMake(0, 100, 100, 100); [btn setTitle:@"click" forState:UIControlStateNormal]; [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; UIImage *image = [UIImage imageNamed:@"btn_01"]; [btn setBackgroundImage:image forState:UIControlStateNormal]; [btn setBackgroundImage:[UIImage imageNamed:@"btn_02"] forState:UIControlStateHighlighted]; [self.view addSubview:btn]; }
//添加button点击事件 self.click方法 [btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
self.headImageView = btn;//相当于连线 监听方法连线
标签:
原文地址:http://www.cnblogs.com/lihaozhou/p/4333462.html