Change the state of a customized button (button with an image)?

前端 未结 6 2399
执笔经年
执笔经年 2021-02-11 09:34

I know how to change the state of the regular button, as well as change the background color of a regular button. However, when I do UIButton:setBackgroundImage (cu

6条回答
  •  离开以前
    2021-02-11 10:28

    I do this in my app using setImage rather than setBackgroundImage, and it works fine for me. The code looks like this:

    [button setImage:[self eraserImageForSize:radius selected:selected]
            forState:UIControlStateNormal];
    

    ...where eraserImageForSize:selected: returns the proper image for the "selected" state (which, in your case, you would simply toggle in the action event).

提交回复
热议问题