標籤:
1:導覽列
//更改狀態列,但是需要加欄位 View controller-based status bar appearance == NO 預設是YES
//[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
//1.設定導航條的顏色
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
//2.關閉導航條的毛半透明效果.
// self.navigationController.navigationBar.translucent = YES;
//3.隱藏導航條
self.navigationController.navigationBar.hidden = NO;
//4.設定導航條內容的渲染顏色
self.navigationController.navigationBar.tintColor = [UIColor purpleColor];
//5.設定導航條的背景圖片.
//圖片尺寸不一樣,顯示的效果是不同的;(一定要非常嚴格)
// [self.navigationController.navigationBar setBackgroundImage:<#(UIImage *)#> forBarMetrics:<#(UIBarMetrics)#>];
//6.設定導航條標題文字的大小和顏色
NSDictionary *dic = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:18], NSForegroundColorAttributeName:[UIColor redColor]};
self.navigationController.navigationBar.titleTextAttributes = dic;
2:
/**
* 針對當前一個介面單獨定製導航條內容
*/
- (void)customizedNavigationBarContent {
//配置導航條上顯示的標題
self.navigationItem.title = @"第一個介面";
//配置導航條的標題視圖
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"國家", @"地區"]];
self.navigationItem.titleView = segment;
//配置左邊內容,顯示廢紙簍按鈕
UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(handleTrash:)]; self.navigationItem.leftBarButtonItem = leftItem;
//配置右邊內容
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(handleAdd:)];
self.navigationItem.rightBarButtonItem = rightItem;
}
/**
* //在對navigationBar進行設定時,比如添加一個scrollView,系統會自動將ScrollView下移偏離TOP 64個像素點,為了避免這樣,我們有兩種方法:
1.將navigationBar的毛半透明效果關閉;
2.將navigationBar的屬性automaticallyAdjustsScrollViewInsets = NO;
iOS導覽列配置問題