How to make custom buttons in iOS?

后端 未结 7 1600
野的像风
野的像风 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:52

    You can use images for buttons using a few simple lines of code:

    // code to set image for button at normal state
    [myButton setImage:[UIImage imageNamed:@"buttonImage.png"] 
              forState: UIControlStateNormal];
    

    You can also use Xcode to change the type to "Custom" then you can set images for each button "state."

    You can read more about UIButton states here

提交回复
热议问题