zoukankan      html  css  js  c++  java
  • UITabBar 设置选中、未选中状态下title的字体颜色

    一、如果只是设置选中状态的字体颜色,使用 tintColor  就可以达到效果

    1. self.tabBar.tintColor = [UIColor redColor];  


    二、但如果要将未选中状态和选中状态下的颜色都改变,可以使用 setTitleTextAttributes:<#(nullable NSDictionary<NSString *,id> *)#> forState:<#(UIControlState)#> 达到效果

    1. [nav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateNormal];  
    2. [nav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor]} forState:UIControlStateSelected];  


           或者

      1. [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateNormal];  
      2. [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor]} forState:UIControlStateSelected]; 
  • 相关阅读:
    Aspect Oriented Programming
    jsp01
    监听器
    Java编写验证码
    servlet07
    MySQL02
    MySQL01
    Java的jdk1.6与jre1.8中存在的差异
    登陆验证和二级联动
    ajax和json
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/9210865.html
Copyright © 2011-2022 走看看