How to make custom buttons in iOS?

后端 未结 7 1508
野的像风
野的像风 2021-02-06 09:01

The default iOS UI is nice but if I wanted to use images for buttons instead how would I do that - is it OpenGL?

7条回答
  •  爱一瞬间的悲伤
    2021-02-06 09:57

    UIButton has a lot of support for custom buttons. In the nib (or storyboard or whatever), just click on the button and set its "Type" to "Custom" in the attribute inspector on the right side of the screen. Then, just below that, set the State Config to the sate you'd like (default, selected, etc) to customize, and set Image attribute to the image you'd like.

    That image must be part of the project first before it will show up in the Image attribute (or in the app). You can add the image to the project simply by dragging it into the file navigator on the left side of the screen.

提交回复
热议问题