简体   繁体   English

导航栏(iPhone)

[英]Navigation bar (iphone)

I have created email functionality view in which everything is working fine, but the color of a navigation bar item is not changing like other views. 我创建了电子邮件功能视图,在该视图中一切正常,但是导航栏项的颜色没有像其他视图一样发生变化。 I have used below code for navigation color but 1 navigation bar button item is left with default color. 我已将以下代码用于导航颜色,但是1个导航栏按钮项保留了默认颜色。 How do I change it? 我该如何更改?

controller.navigationBar.barStyle = UIBarStyleBlack;

How about use this? 怎么使用呢?

self.navigationController.navigationBar.tintColor = [UIColor blackColor];

of course on your viewDidLoad 当然在您的viewDidLoad

Do you create the bar button item yourself? 您自己创建条形按钮项吗? If so, you can change its background color by making sure it's a "custom view" type button item: 如果是这样,可以通过确保它是“自定义视图”类型的按钮项来更改其背景颜色:

// Assuming you have some predetermined width w and height h
UIView *backgroundView = [[[UIView alloc] 
                           initWithFrame:CGRectMake(0.0, 0.0, w, h)] autorelease];
backgroundView.backgroundColor = [UIColor blackColor];
UIBarButtonItem *myItem = [[[UIBarButtonItem alloc]
                            initWithCustomView:backgroundView] autorelease];

Then you can change the background color at a future date by setting the backgroundColor property on the bar button item's customView : 然后,您可以在将来的某个日期通过设置条形按钮项的customViewbackgroundColor属性来更改背景色:

myItem.customView.backgroundColor = [UIColor yellowColor];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM