iOS 导航栏的属性设置

  iOS中设置导航栏背景、字体属性

---------------------------------------------------

1、自定义导航控制器作为基类,在 + (void)initialize 方法中设置偏好设置,不要在 + (void)load 方法中设置

+ (void)initialize {

    // 设置 两侧按钮 的颜色tintColor(标题除外)

    [[UINavigationBar appearance] setTintColor:FGCOLOR]; // FGCOLOR 设置返回按钮的颜色tintColor(标题除外)

    // 导航栏 背景色

    [[UINavigationBar appearance] setBarTintColor:BGCOLOR];

    // 标题属性

    [[UINavigationBar appearance] setTitleTextAttributes:@{

                                                           NSForegroundColorAttributeName:[UIColor colorWithRGBHex:0x333333],

                                                           NSFontAttributeName : [UIFont systemFontOfSize:18]

                                                           }];

    

    // 设置 导航栏按钮 文字颜色(标题除外)

    /*

    UIBarButtonItem *item = [UIBarButtonItem appearance];

    NSDictionary *atts = @{

                           NSForegroundColorAttributeName : [UIColor colorWithRGBHex:0xff0000]

                           };

    

    [item setTitleTextAttributes:atts forState:UIControlStateNormal];

     */

}

posted @ 2016-10-03 20:34  jaly2012  阅读(259)  评论(0编辑  收藏  举报