这可能与Pixate Freestyle: clear styleClass property does not reset 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
}
弹出视图控制器并返回到父viewController:
-(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];
*/
}
答案 0 :(得分:0)
我在这里找到答案:Styling UINavigationBar Part 2
我在Freestyle网站上使用文档并尝试使用按钮外观。
正确的样式现在是右键 - 按钮和左键 - 按钮。
navigation-bar {
opacity: 1;
color: black;
background-color: white;
}
navigation-bar title {
color: black;
}
navigation-bar right-bar-button, navigation-bar left-bar-button {
color: black;
}
navigation-bar.he {
background-color: darkgreen;
color: black;
}
navigation-bar.he title {
color: black;
}
navigation-bar.he right-bar-button, navigation-bar.he left-bar-button {
color: black;