keeping a UIButton pressed(state selected/highlighted),until another button is pressed?

前端 未结 3 1367
庸人自扰
庸人自扰 2021-02-09 19:26

I have 3 buttons at the bottom of my view controller, btn1 btn2 btn3, I\'m using them instead of the tab bar as it is not possible to entirely customize a tab bar as per my requ

3条回答
  •  天涯浪人
    2021-02-09 19:54

    What you did is set an image for the "Highlighted" state, this is why when you push it you can see your image.

    What you want to do is

    1) set the image for the SELECTED state

    2) create a property for your view controller (just controll drag the button to the header) using the assistant view (while on storyboard, second square on the top right)

    3) on your method for the button's action type:

    button.selected = !button.selected;
    

    (obviously replace button to whatever you named your property to)

提交回复
热议问题