On the tech talk 2011 I saw a speech about the new UIAppearance
protocol. There is not a lot of documentation out there yet. I will shortly summarize what I remember to explain where my question is coming from:
About UIAppearance
:
So far you had to customize EVERY navigation bar (toolbar, etc.) property in all your app view controllers. With the new appearance property you can do it in only one place for all navigation bars in your app. For instance: if you want to customize your Navigation bar background image you could do it like this:
[[UINavigationBar appearance] setBackgroundImage:
[UIImage imageNamed:@"MyImageName"] forBarMetrics:UIBarMetricsDefault];
This will set the background image of ALL navigation bars within your application. With the barMetrics
you specify whether you want the image to be used also in landscape mode or not.
If you want to specify the appearance to be applied only in some view controllers there is also a method in the docs to control that by specifying where your objects are located:
[[UIBarButtonItem appearanceWhenContainedIn:
[ABPeoplePickerNavigationController class], nil] setTintColor:myNavBarColor];
Also worth to mention is, if you have single customized instances, differing from your appearance settings, theses instances will not be effected by the appearance proxy.
Some questions:
a) How do I know which properties of a class work with the appearance property? For e.g. since UITableView
conforms to the UIAppearance protocol I was thinking I could do something like
[[UITableView appearance] setBackgroundColor:mytableViewColor];
to manipulate the background color of all my table views, but I can't!
b) Is there a list of all classes that are manipulatable with the appearance property?
c) At what point is the appearance customization being called? I was hoping to make changes threw the appearance property at runtime, but unfortunately the changes aren't taking place.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…