What is the best way to make a UIButton checkbox?

后端 未结 9 1495
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 04:03

I am trying to make a standard check box for my iPhone app from a UIButton with a title and image. The button image changes between an \"unchecked\" image and

9条回答
  •  孤街浪徒
    2020-12-14 04:38

        UIImage* nonCheckedImage=[UIImage imageNamed:@"ic_check_box_outline_blank_grey600_48dp.png"];//[UIImage init
        UIImage* CheckedImage=[UIImage imageNamed:@"ic_check_box_black_48dp.png"];//[UIImage init
    
        //ic_check_box_black_48dp.png
        [_checkBox setImage:CheckedImage forState:UIControlStateSelected];
        [_checkBox setImage:nonCheckedImage forState:UIControlStateNormal];
    }
    
    - (IBAction)checkBoxToggle:(id)sender {
        _checkBox.selected = !_checkBox.selected; // toggle the selected property, just a simple BOOL
    
    }
    

    the image you can use google icon

提交回复
热议问题