-(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];    
}

相关文章:

  • 2021-12-15
  • 2021-10-22
  • 2022-12-23
  • 2021-08-02
  • 2021-09-27
  • 2021-10-13
  • 2021-12-26
  • 2021-10-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2021-12-05
  • 2021-12-15
相关资源
相似解决方案