設置背景顏色
self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
設置字體顏色
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
或者
[self.navigationController.navigationBar setTitleTextAttributes:@{UITextAttributeTextColor : [UIColor whiteColor]}];
添加系統自帶的按鈕
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"style:UIBarButtonItemStyleDone target:nil action:nil];
self.navigationItem.rightBarButtonItem = rightButton;
自定義item
UIButton *servicebtn = [UIButton buttonWithType:UIButtonTypeCustom];
servicebtn.frame = CGRectMake(0, 0, 30, 30);
[servicebtn setBackgroundImage:[UIImage imageNamed:@"user"] forState:UIControlStateNormal];
[servicebtn addTarget:self action:@selector(callService) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:servicebtn];
self.navigationItem.rightBarButtonItem = item;