How can I create a "glow" UIBarButtonItem?

In the Maps application, when you click the tracking button in the lower left corner, it lights up to show that it is pressed. This makes him behave like a radio button, and he will not burn after moving the card. Is there an easy way, but the button is down?

+3
source share
5 answers

Set your UIBarButtonItemStyleDone style.

+10
source

I believe that you are looking for the showTouchWhenHighlighted property for the UIButton class. Try it.

myButton.showsTouchWhenHighlighted = YES;
+11
source

:

`

UIImage *image = [UIImage imageNamed:@"someimage"];
UIImage *imageHL = [UIImage imageNamed:@"someimage_selected"];
button = [UIButton buttonWithType:UIButtonTypeCustom];

[button setImage:image forState:UIControlStateNormal];
[button setImage:imageHL forState:UIControlStateHighlighted];
[button addTarget:self action:@selector(doStuff:) forControlEvents:UIControlEventTouchUpInside];    
myBarButtonItem.customView = button;

`

+3

UIBarButtonItemStylePlain.

UIBarButtonItemStylePlain
Glow on click.

+1
source

If you have a UIBarButtonItem with image/textor UIBarButtonSystemItem, useUIBarButtonItemStylePlain

barButton.style = UIBarButtonItemStylePlain;

If you have a UIBarButtonItem with a custom view, UIButtonadd the following code for each :

uiButton.showsTouchWhenHighlighted = YES;
0
source

Source: https://habr.com/ru/post/1741688/


All Articles