Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用UINavigationBar appearance无法修改导航栏样式 #12

Closed
songhailiang opened this issue Jul 11, 2016 · 7 comments
Closed

使用UINavigationBar appearance无法修改导航栏样式 #12

songhailiang opened this issue Jul 11, 2016 · 7 comments

Comments

@songhailiang
Copy link

我在AppDelegate里使用UINavigationbar appearance无法修改导航栏的样式:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:58/255.0 green:58/255.0 blue:58/255.0 alpha:1.0]]; [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor],NSForegroundColorAttributeName ,[UIFont systemFontOfSize:20.0], NSFontAttributeName, nil]];
没有任何效果

@rickytan
Copy link
Owner

直接改 root navigation controller ,然后设置 transferNavigationBarAttributes 设置为 YES 也可以的

@songhailiang
Copy link
Author

嗯,但是我觉得这样可能用起来并不是很方便,因为App里很有可能会present其他的NavigationController,这样的话就得设置每个NavigationController的样式。UINavigationBar appearance是设置默认样式的,我觉得应该支持一下比较好。
您的这个库正式我所需要的,因为我的APP已经完成了,如果要使用的话,可能改动会比较大,我还在评估修改量。非常感谢!

@rickytan
Copy link
Owner

如果你用的 storyboard ,只要改个 Class 名 😄
有空再看,本应该直接支持的

@songhailiang
Copy link
Author

我大概找到原因了,是在transferNavigationBarAttributes=YES时,给self.navigationBar设置样式时没有考虑appearance里的值,我改成这样就可以了,不知道代码严不严谨,还望指教:
self.navigationBar.tintColor = [UINavigationBar appearance].tintColor ?: self.navigationController.navigationBar.tintColor;

@rickytan
Copy link
Owner

那你设置为 NO 试试?

@rickytan
Copy link
Owner

我试过了,是直接支持的,你要在最开始设置 appearance

@rickytan
Copy link
Owner

第一个有用,后来 push 的没用,已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants