[英]How to change UINavigationBar Title and Back Button Colour from Storyboard?
[英]How to change the colour of back button?
我有一个地图,屏幕顶部只有一个后退按钮。 由于某种原因,它不会为我改变颜色。 这是我在委托中用来更改委托中另一个后退按钮的代码。
UIBarButtonItem *barButtonAppearance = [UIBarButtonItem appearance]; [barButtonAppearance setTintColor:[UIColor blackColor]];
干杯!
要更改单个按钮的文本颜色,您可以将属性字符串设置为其标题:
NSDictionary *attributes = @{NSForegroundColorAttributeName: [UIColor redColor]};
[button setTitleTextAttributes:attributes forState:UIControlStateNormal];
要更改导航栏中所有按钮的颜色,请尝试:
self.navigationController.navigationBar.tintColor = [UIColor redColor];
如果您使用的是图像而不是文本,则最后一个颜色也会更改色调颜色。
两种方法均在iOS7之前进行了测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.