Iphone - How can I use UIBarButtonItem style without UIToolBar

Can I show a UIBarButtonItem with a black style in my view without a bottom UIToolBar?

UIToolBar always has a kind of borderline thing, I want the UIBarButtonItem system to be black, like the black cancel button, but not the UIToolBar

How can i do this?

thank

+3
source share
2 answers

There is a cheeky hack that will help you with this.

you want to use a UISegmentedControl with the style set to UISegmentedControlStyleBar, and only one element. You also need setMomentaryto yes - make it behave like a button:

UISegmentedControl *myCustomButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Hello",nil]];
[myCustomButton setSegmentedControlStyle:UISegmentedControlStyleBar];
[myCustomButton setTintColor:[UIColor blackColor]];
[myCustomButton setMomentary:YES];
[self.view addSubview:myCustomButton];

, UIBarButtonItem, , . .:)

, : - :

alt text

+3

, - alpha UIToolBar , UIBarButtonItem. UIBarButtonItem .

UIToolBar UIView, - backgroundColor clearColor.

0

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


All Articles