I'd like to indicate that a particular UIBarButtonItem
is toggled on or off by changing its background color. Mobile Safari uses this feature to indicate whether private browsing is on or off:
How can I do this, since there's no backgroundColor
property on UIBarButtonItem
?
You could instead just use two images. One for selected and one for unselected
The above function should help you do this
Create a
UIButton
and use it as the custom view for theUIBarButtonItem
. Then, set thebackgroundColor
on the button's layer: