UIBarButtonItemStyleDone Background Image Using iOS 5 Appearance API

How can I provide a visually excellent background image of a panel item for buttons with a UIBarButtonItemStyleDone style and the edit status of the Edit / Done button? None of the documented UIControlState values ​​in the UIBarButtonItem proxy setBackgroundImage: forState: barMetrics: seems to do the trick.

+6
source share
2 answers

I'm not sure why they never answered about this, but if you're still looking, just create a property for BarButtonItem in your .h, assign it to IB, and then set the background property of this barButtonItem. Works fine for me and never "reverts to the default look."

- (void)viewDidLoad { [super viewDidLoad]; [self.barButton setBackgroundImage:[UIImage imageNamed:@"YOURIMAGE"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; } 
+1
source

I just found and published a possible solution to this problem. You can “enter” custom styles using the UIBarButtonItem category:

Customize the UIBarButtonItem “Finish” style and the “Normal” style separately using UIAppearance

0
source

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


All Articles