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

前端 未结 6 2266
执笔经年
执笔经年 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:29

    UIButton *b = [UIButton buttonWithType:UIButtonRoundedRect];
    b.frame = CGRectMake(X,Y,H,W);
    
    // set a different background image for each state
    [b setBackgroundImage:myNormalBackgroundImage forState:UIControlStateNormal];
    [b setBackgroundImage:mySelectedBackgroundImage forState:UIControlStateSelected];
    

提交回复
热议问题