为 iPhone 导航栏着色时,颜色和按钮会改变行为
我想知道为什么当我做这样的事情时,一切都会停止表现:
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
导航栏上的所有按钮现在都是黑色的,无论样式如何,就像下面的这个,它应该显示为蓝色按钮:
UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleDone target:self action:@selector(editTrip)];
它不是,它是只是黑色。
点击按钮时的轻微变化/效果也消失了?
有没有办法改变 navigationBar 甚至 UIbarButtonItems 的颜色而不以某种方式破坏标准行为?
这实在是太奇怪了。我刚刚检查了苹果的“远程”应用程序,它有黑色的导航栏和一个蓝色的“完成”按钮,用于离开“帮助”部分。
我真的必须定制一切才能实现这一目标吗?
感谢您提供的任何帮助:)
I was wondering why everything stops behaving as it should when I do something like this:
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
All my buttons on the navigationBar are now black regardless of style, like this one below, it should turn up as a blue button:
UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleDone target:self action:@selector(editTrip)];
It does not, it is just black.
The slight change/effect in the button when tapped is also gone?
Is there a way to change the color of the navigationBar and maybe even the UIbarButtonItems without somehow ruining standard behavior?
This is really strange. I just checked with the Apple "Remote" app, it has the black navigation bar and a blue "Done" button for leaving the "help" section.
Do I really have to build everything custom to achieve this?
Thanks for any help given:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Interface Builder 中,将导航栏的样式更改为黑色不透明或黑色半透明,并保留色调。这将为您提供一个带有标准蓝色按钮的黑色条。
我确信在没有 Interface Builder 的情况下在代码中执行此操作的方法是将
barStyle
属性设置为UIBarStyleBlack
或UIBarStyleBlackTranslucent
,但我没有没有这样做。In Interface Builder, change the Style of the Navigation Bar to Black Opaque or Black Translucent and leave the tint alone. This will give you a black bar with the standard blue buttons.
I'm sure the way to do this in code without Interface Builder, is by setting the
barStyle
property toUIBarStyleBlack
orUIBarStyleBlackTranslucent
, but I haven't done it that way.