What is the best way to make a UIButton checkbox?

后端 未结 9 1453
佛祖请我去吃肉
佛祖请我去吃肉 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:51

    Set the images in the button:

    [button setImage:uncheckedImage forState:UIControlStateNormal]
    [button setImage:checkedImage forState:UIControlStateSelected]
    

    Now all you need to do is:

    button.selected = state
    

    and the correct images will display.

提交回复
热议问题