iOS導覽列配置問題

來源:互聯網
上載者:User

標籤:

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導覽列配置問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.