在2011年科技讲座上,我看到了一篇关于新UIAppearance
protocol的演讲.目前还没有太多的文档.我将简要总结一下我记得要解释的问题的来源:
About 100:
到目前为止,您必须自定义所有应用程序视图控制器中的每个导航栏(工具栏等)属性.有了新的外观属性,你可以在应用程序中的所有导航栏中只在一个位置执行此操作.例如:如果你想定制你的导航栏背景图像,你可以这样做:
[[UINavigationBar appearance] setBackgroundImage:
[UIImage imageNamed:@"MyImageName"] forBarMetrics:UIBarMetricsDefault];
这将设置应用程序中所有导航栏的背景图像.使用barMetrics
可以指定是否希望图像也在横向模式下使用.
如果要指定仅在某些视图控制器中应用的外观,文档中还有一种方法可以通过指定对象的位置来控制该外观:
[[UIBarButtonItem appearanceWhenContainedIn:
[ABPeoplePickerNavigationController class], nil] setTintColor:myNavBarColor];
另外值得一提的是,如果您有一个自定义实例,与您的外观设置不同,这些实例将不受外观代理的影响.
Some questions:
a) How do I know which properties of a class work with the appearance property?例如,由于UITableView
符合UIAppearance协议,我想我可以这样做
[[UITableView appearance] setBackgroundColor:mytableViewColor];
操纵所有表格视图的背景色,但我不能!
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?我希望在运行时对外观属性进行更改,但不幸的是更改没有发生.