0

I set a UIAppearance for a UIBarButtonItem in a UINavigationController like this:

[[UIBarButtonItem appearanceWhenContainedIn: [UINavigationController class],nil] setBackgroundImage:bimg forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearanceWhenContainedIn: [UINavigationController class],nil] setTitlePositionAdjustment:UIOffsetMake(0, bimg.size.height*2) forBarMetrics:UIBarMetricsDefault];

but it seems to be affecting UIBarButtonItems inside a UIToolBar as well. what I want to do is , I have custom buttons in the navigationBar, but i'm using a UIToolbar above the keyboard and I want those buttons to remain stock iOS style.

Is there any way to revert the UIAppearance? Or can I explicitly set the UIAppearance of a UIBarButtonItem inside a UIToolbar to use default?

Nishant Tyagi
  • 9,893
  • 3
  • 40
  • 61
roocell
  • 2,429
  • 25
  • 28

1 Answers1

1

Use UINavigationBar instead of UINavigationController:

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class],nil] setBackgroundImage:bimg forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class],nil] setTitlePositionAdjustment:UIOffsetMake(0, bimg.size.height*2) forBarMetrics:UIBarMetricsDefault];
Michael Reneer
  • 2,271
  • 1
  • 16
  • 22