码迷,mamicode.com
首页 > 其他好文 > 详细

自定义复选框按钮

时间:2016-09-05 17:08:40      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

-(void)checkboxClick:(UIButton *)btn
{
    btn.selected = !btn.selected;
}


- (void)viewDidLoad {
UIButton *checkbox = [UIButton buttonWithType:UIButtonTypeCustom];
    
    CGRect checkboxRect = CGRectMake(135,150,36,36);
    [checkbox setFrame:checkboxRect];
    
    [checkbox setImage:[UIImage imageNamed:@"checkbox_off.png"] forState:UIControlStateNormal];
    [checkbox setImage:[UIImage imageNamed:@"checkbox_on.png"] forState:UIControlStateSelected];
    
    [checkbox addTarget:self action:@selector(checkboxClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:checkbox];    
}

自定义复选框按钮

标签:

原文地址:http://www.cnblogs.com/zhanglei8831/p/5842605.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!