Set a button background image iPhone programmatically

后端 未结 8 426
无人及你
无人及你 2020-12-13 14:25

In Xcode, how do you set the background of a UIButton as an image? Or, how can you set a background gradient in the UIButton?

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 15:00

    In one line we can set image with this code

    [buttonName setBackgroundImage:[UIImage imageNamed:@"imageName"] forState:UIControlStateNormal];
    

提交回复
热议问题