Search code examples
objective-cios8uinavigationbaruiappearance

UIAppearance for UINavigationBar ios8


In my application currently I have implemented custom view in place of UINavigationBar. But there are 14-15 screens. So I repeatedly created that top view fro each screen.

So while surfing for the solution to avoid this repetition. I came across the concept of UIAppearance. But I don't know how to implement it. I have also gone through some basic concept of it but still I am very confuse.

My top view is bit different for each screen. Like in 4-5 screens there is Two buttons(back button on left and call button right) with one label in center.

Then in other 4-5 screens there is two buttons(cancel button on left and call button on right) with one label in center.

Then in other 2-3 screens there are two buttons(side menu button on left and call button on right) with one label and icon in center.

Can anyone tell me how to achieve it using UIAppearance? Thanks in advance!


Solution

  • You can't set buttons via UIAppearance. If you are setting titleTextAttributes on each page (for say, font, size and color), you can do that via the UINavigationBar appearance like this:

    [[UINavigationBar appearance] setTitleTextAttributes:attributes];
    

    The attributes pointer is a NSDictionary containing your textAttributes (NSFontAttributeName, NSForegroundColorAttributeName etc.)