这可能与Pixate Freestyle 相同的问题:清除 styleClass 属性不会重置 style。但我说不出来。
我设计了 UINavigationBar 和标题以及左右按钮。我的视图是表格视图。当我选择一个单元格时,当我在堆栈上推送一个新视图时,我会重新设置导航栏的样式。
当我弹出视图时,我希望旧样式生效。但是按钮不会重新设置样式。
CSS:
navigation-bar {
opacity: 1;
color: black;
background-color: white;
}
navigation-bar title {
color: black;
}
navigation-bar button-appearance {
color: black;
}
navigation-bar.he {
background-color: darkgreen;
color: white;
}
navigation-bar.he button-appearance {
color: white;
}
navigation-bar.he title {
color: white;
}
推送一个新的视图控制器工作:
-(void)viewDidLoad {
self.navigationController.navigationBar.styleClass = [self.dict objectForKey:CLASS]; // Imagine this is he
}
弹出视图控制器并返回父视图控制器:
-(void)viewWillAppear:(BOOL)animated
{
// This updates the bar and title but not the buttons
self.navigationController.navigationBar.styleClass = @"";
[self.navigationController.navigationBar updateStyles];
[self.navigationController.navigationItem updateStyles];
[self.navigationItem.rightBarButtonItem updateStyles];
/* Hack ...
if(self.navigationItem.rightBarButtonItem!=nil)
self.navigationItem.rightBarButtonItem.tintColor = [UIColor blackColor];
if(self.navigationItem.leftBarButtonItem!=nil)
self.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
*/
}