首页 > 移动平台 > 详细

checkbox in iOs

时间:2015-03-10 23:06:44      阅读:351      评论:0      收藏:0      [点我收藏+]
UIButton *checkbox;
BOOL checkBoxSelected;
checkbox = [[UIButton alloc] initWithFrame:CGRectMake(x,y,20,20)
// 20x20 is the size of the checckbox that you want
// create 2 images sizes 20x20 , one empty square and
// another of the same square with the checkmark in it
// Create 2 UIImages with these new images, then:

[checkbox setBackgroundImage:[UIImage imageNamed:@"notselectedcheckbox.png"] forState:UIControlStateNormal];
[checkbox setBackgroundImage:[UIImage imageNamed:@"selectedcheckbox.png"] forState:UIControlStateSelected];
[checkbox setBackgroundImage:[UIImage imageNamed:@"selectedcheckbox.png"] forState:UIControlStateHighlighted];
checkbox.adjustsImageWhenHighlighted=YES;
[checkbox addTarget.....]
[self.view addSubview:checkbox];

Now in the target method do the following:

-(void)checkboxSelected:(id)sender {
    checkboxSelected = !checkboxSelected; /* Toggle */
    [checkbox setSelected:checkboxSelected];
}

 

checkbox in iOs

原文:http://www.cnblogs.com/welhzh/p/4328604.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!