UITabbar 中的 item的字体颜色 item点击后的tint颜色 和图片颜色的修改 UINavigationBar字体设置


[[UITabBar appearance] setTintColor:[UIColor colorWithRed:0.0
                                                    green:176.0/255.0
                                                     blue:226.0/255.0
                                                    alpha:1.0]];

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                   [UIColor lightGrayColor], UITextAttributeTextColor, nil]
                                         forState:UIControlStateNormal];

UITabbar有个setTintColor这个方法,可以理解为,高亮的时候,或者点击后的颜色设置。

UITabBarItem有个setTitleTextAttributes的方法,是用来设置字体的颜色。

我这里是在viewDidLoad添加的。

代码如下:

//设置tabbar的背景图片
UITabBar *tabBar = self.tabBarController.tabBar;
[tabBar setTintColor:[UIColor colorWithRed:0.0
                                     green:176.0/255.0
                                      blue:226.0/255.0
                                     alpha:1.0]];
tabBar.selectedImageTintColor = [UIColor clearColor];
UITabBarItem *item = [tabBar.items objectAtIndex:0];
NSString *homePath = [[NSBundle mainBundle] pathForResource:@"btn_home_highlight" ofType:@"png"];
if(item.tag == 1)
{
    [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                  [UIColor lightGrayColor], UITextAttributeTextColor, nil]
                        forState:UIControlStateNormal];
    item.selectedImage = [UIImage imageWithContentsOfFile:homePath];
}

再看下面代码

UITabBarItem *tabBarItem1=self.tabBar.items[0];

    UITabBarItem *tabBarItem2=self.tabBar.items[1];

    tabBarItem1.image = [[UIImage imageNamed:@"iconAccount"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    tabBarItem1.selectedImage = [[UIImage imageNamed:@"iconAccountOn"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    tabBarItem2.image = [[UIImage imageNamed:@"iconFortune"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    tabBarItem2.selectedImage = [[UIImage imageNamed:@"iconFortuneOn"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

  //  tabBarItem2.badgeValue=@"10";

    //设置正常状态字体

    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary

                                        dictionaryWithObjectsAndKeys: [UIColor blackColor],

                                        NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];

    //设置选中状态字体

    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary

                                                       dictionaryWithObjectsAndKeys: [UIColor colorWithRed:255/255 green:56/255 blue:0 alpha:1.0],

                                                       NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];

    

   // self.tabBar.tintColor=[UIColor colorWithRed:255/255 green:56/255 blue:0 alpha:1.0];

UINavigationBar设置title字体大小颜色

UINavigationBar *navBar = [UINavigationBar appearance];

    [navBar setBackgroundColor:COLOR_MAKE(BACKGROUND_RED_VALUE, BACKGROUND_GREEN_VALUE, BACKGROUND_BLUE_VALUE)];

  

//修改navBar字体大小文字颜色

NSDictionary *attris = @{ NSFontAttributeName:[UIFont systemFontOfSize:NAV_TITLE_TEXT_SIZE],

                      NSForegroundColorAttributeName:[UIColor blackColor] };

[navBar setTitleTextAttributes:attris];

导航栏颜色设置

 if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)) {

        

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

        

//        [[UINavigationBar appearance] setTranslucent:NO];

        

    }

    

    else

    {

        [[UINavigationBar appearance] setTintColor:[UIColor orangeColor]];

    }

设置navigationItem 颜色

self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0/255.0 green:205.0/255.0 blue:205.0/255.0 alpha:1.0];

设置状态栏时间电池运营商颜色 (白色)

info->Custom iOS Target Properties

+ View controller-based status bar appearance 设置为NO

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

    /**

     *  改变后需要及时刷新的调用

     */

    [self setNeedsStatusBarAppearanceUpdate];

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值