Set a button background image iPhone programmatically

后端 未结 8 433
无人及你
无人及你 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:14

    You can set an background image without any code!

    Just press the button you want an image to in Main.storyboard, then, in the utilities bar to the right, press the attributes inspector and set the background to the image you want! Make sure you have the picture you want in the supporting files to the left.

提交回复
热议问题