I’m doing a custom nav in ios for the first time. I have six buttons laid out in a row. When I tap the button, I want the image to change. However, the button is not togglable. The only way a button can be unselected is if another button is touched. Only one button can be active at any given time.
My idea:
- use
UIButtons - change UIButton image on touch
- keep track of the active button inside the navigation class
- when an inactive button is touched, make the currently active button inactive and turn the touched button to active
I want the end product to work like a custom TabBarController, but without switching layouts. I just want to edit the content in the current ViewController.
Is there a better way to do this?
I setup the
UIButtonsin the Interface Builder like so:On touch, a button is
self.enabled = NOwhich makes theUIButtonslook change. However, the button goes dim, so I also implementedself. adjustsImageWhenDisabled = NO.This way a button can’t be re-selected once it’s “active”.