anc*_*evv 0 iphone objective-c uinavigationbar uinavigationcontroller
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
{
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancel)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Send to Twitter"
style:UIBarButtonItemStyleDone
target:self
action:@selector(save)];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
另一段代码
- (void)loadView
{
[super loadView];
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
self.view.backgroundColor = [UIColor whiteColor];
self.textView = [[UITextView alloc] initWithFrame:self.view.bounds];
textView.delegate = self;
textView.font = [UIFont systemFontOfSize:15];
textView.contentInset = UIEdgeInsetsMake(5,5,0,0);
textView.backgroundColor = [UIColor whiteColor];
textView.autoresizesSubviews = YES;
textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:textView];
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试将导航栏颜色更改为黑色,但无论我在这里做什么,颜色仍然保持默认(蓝色).如何更改视图顶部栏的颜色?

尝试类似的东西:
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
应该是这样的对viewWillAppear:作为在init方法self.navigationController会获得nil,因此不会产生任何影响.
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
2363 次 |
| 最近记录: |