2013-05-08 49 views
1

我已经玩过UIAppearance了一点点,它工作正常。目前,我正在AppDelegate中设置所有外观,但现在我需要在App启动后进行一些自定义(用户登录后进行主题化)。UIAppearance是否在AppDelegate之外工作?

是否可以将外观的东西放在AppDelegate之外?当然,我已经尝试过,但它没有效果。我是否需要重新加载Wohle App-UI,如果有,我该怎么做?

谢谢!

克里斯

+1

如果在创建视图对象后更改'UIAppearance',则不会影响它们。您必须重新加载/重新实例化这些对象。我无法在文档中找到它,但似乎是这样。 – 2013-05-08 11:46:34

回答

1

如果您正在使用XIB创建您的视图,你应该做的AppDelegate内的外观定制,因为定制应该创建任何UIControl对象之前进行。可以使用appearanceWhenContainedIn

要定制的外观用于在层次结构包含在容器类的实例中的类的实例,或实例自定义为不同视图控制器/容器,使用+ appearanceWhenContainedIn:用于适当的外观代理。

例如:

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:myNavBarColor]; 
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], [UIPopoverController class], nil] setTintColor:myPopoverNavBarColor]; 

使用的ViewController类

[[UIStepper appearanceWhenContainedIn:[MainViewController class], nil]setTintColor:[UIColor redColor]]; 
[[UIStepper appearanceWhenContainedIn:[DetailViewController class], nil]setTintColor:[UIColor greenColor]]; 

如果你正在创建的控制程序,无论自定义刚刚创建控制

前3210
相关问题