天天看點

iOS 導覽列的基本用法

   //導覽列标題

    self.navigationItem.title = @"title";

    //導覽列傳回時文字的設定

    self.navigationController.navigationBar.topItem.title= @"";

    //去掉導覽列傳回時文字

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];

    //導覽列傳回時箭頭顔色的設定

    self.navigationController.navigationBar.tintColor = [UIColor redColor];

    //導覽列的顔色

    self.navigationController.navigationBar.barTintColor =[UIColor blackColor];

    //隐藏傳回按鈕

    self.navigationItem.hidesBackButton = YES;

    //設定導覽列背景顔色

    [[UINavigationBar appearance]setBarTintColor:[UIColor redColor]];

    //設定導覽列背景圖檔

    [[UINavigationBar appearance]setBackgroundImage:[UIImage p_w_picpathNamed:@"ios"] forBarMetrics:UIBarMetricsDefault];

    //設定導覽列标題的顔色和字型大小

    [self.navigationController.navigationBar setTitleTextAttributes:

     @{NSFontAttributeName:[UIFont systemFontOfSize:19],

        NSForegroundColorAttributeName:[UIColor redColor]}];