checkbox in iOs
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]; }
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
支付宝扫一扫捐赠
支付宝扫一扫捐赠
微信公众号: 共鸣圈
欢迎讨论,邮件: 924948$qq.com 请把$改成@
QQ群:263132197
QQ: 924948
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步