Reset appearance parameters for UINavigationBar will return to default

I use the fantastic [[UINavigationBar appearance] set... to install applications for my interface. However, I am using SKStoreProductViewController and want to remove my entire style so that it displays Apple's default user interface. Oddly enough, I do nothing, I get a target of the regular user interface and my user interface, which I really do not understand. I tried to counteract all the changes in my user interface:

  [storeController.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; [storeController.navigationController.navigationBar setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: nil, UITextAttributeTextColor, nil, UITextAttributeTextShadowColor, nil]]; [storeController.navigationController.navigationBar setTitleVerticalPositionAdjustment:0 forBarMetrics:UIBarMetricsDefault]; [storeController.navigationController.navigationItem.leftBarButtonItem setBackgroundVerticalPositionAdjustment:0 forBarMetrics:UIBarMetricsDefault]; 

But this does not seem to work without changing anything. How can I return it to the default user interface settings?

Yours faithfully,
Mike

+7
source share
2 answers

Well, then I had to resort to an unpleasant workaround to fix this problem. Although I always knew that this would be one way to do this, I did not want to resort to him because he feels dirty.

I subclassed the UINavigationController to something like CustomNavigationViewController and did not make any changes to it. In other words, this is an IS UINavigationController , but with a different name. Then I used:

[[UINavigationBar appearanceWhenContainedIn:[CustomNavigationViewController class], nil] set.... to set the appearance by applying it only to those navigation controllers that belong to my custom class. SKStoreProductViewController obviously does not apply to my custom class and therefore does not get a style for it.

This, in my opinion, is an unpleasant, unclean solution, but it works.

Mike.

+7
source

You can be very specific about styling these elements with the UIAppearance proxy. This method has a method that applies the style only when it is contained in a particular class of the view controller.

There is a good tutorial here :

0
source

All Articles