首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pixate Freestyle -在UINavigationBar上动态设置样式

Pixate Freestyle -在UINavigationBar上动态设置样式
EN

Stack Overflow用户
提问于 2014-07-05 10:18:55
回答 1查看 469关注 0票数 0

这可能是与Pixate Freestyle: clear styleClass property does not reset style相同的问题。但我看不出来。

我已经设置了UINavigationBar、标题和左、右按钮的样式。我的视图是表格视图。当我选择一个单元格时,当我在堆栈上推送一个新视图时,我会重新设置导航栏的样式。

当我弹出视图时,我希望旧样式生效。但是,按钮不会重新设置样式。

CSS:

代码语言:javascript
复制
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;
}

推送一个新的视图控制器工作:

代码语言:javascript
复制
-(void)viewDidLoad {
    self.navigationController.navigationBar.styleClass = [self.dict objectForKey:CLASS]; // Imagine this is he
}

弹出视图控制器并返回父viewController:

代码语言:javascript
复制
-(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];
    */
}
EN

回答 1

Stack Overflow用户

发布于 2014-07-05 16:51:25

我在这里找到了答案:Styling UINavigationBar Part 2

我正在使用Freestyle网站上的文档,并尝试使用按钮外观。

正确的样式现在是右栏按钮和左栏按钮。

代码语言:javascript
复制
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;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24582391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档