iOS設置或修改導航欄按鈕、標題

1. 設置導航欄返回按鈕:

UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];

    button.frame = CGRectMake(0, 0, 44, 30);

    [button setImage:[UIImage imageNamed:@"leftArrow"] forState:UIControlStateNormal];

    button.imageView.contentMode = UIViewContentModeScaleAspectFit;

    [button addTarget:self action:@selector(DismissViewController:) forControlEvents:UIControlEventTouchUpInside];

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];


2. 設置導航欄背景圖片:

    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"grayNavBack"] forBarMetrics:UIBarMetricsDefault];


3. 取消導航欄橫線:

    [self.navigationController.navigationBar setShadowImage:[UIImage new]];




發佈了33 篇原創文章 · 獲贊 4 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章