修改UITabBarItem的字体颜色

修改UITabBarItem下面字体的颜色,如图:

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

[[UITabBarItem
appearance] setTitleTextAttributes:   [NSDictionary
dictionaryWithObjectsAndKeys:[UIColor
redColor],UITextAttributeTextColor,
nil]forState:UIControlStateSelected];

这个时候会报警告‘UITextAttributeTextColor‘
is deprecated in iOS 7. The iOS 7 key is ‘NSForegroundColorAttributeName

然后替换一下就可以了,不过NSForegroundColorAttributeName最底支持到ios6.0

[[UITabBarItem
appearance] setTitleTextAttributes:[NSDictionary
dictionaryWithObjectsAndKeys:[UIColor
blackColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateNormal];

[[UITabBarItem
appearance] setTitleTextAttributes:  [NSDictionary
dictionaryWithObjectsAndKeys:[UIColor
redColor],NSForegroundColorAttributeName,
nil]forState:UIControlStateSelected];

时间: 2024-08-29 17:15:15

修改UITabBarItem的字体颜色的相关文章

iOS修改UIButton setTitle字体颜色和调整字体位置

调整Title字体位置 [button setTitleEdgeInsets:UIEdgeInsetsMake(10, 0, 0, 0)]; 四个参数分别代表:上边界,左边界,下边界,右边界 修改UIButton setTitle字体颜色 [button addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];

修改placeholder的字体颜色

第一种 UIColor *color = [UIColor whiteColor]; _userName.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用户名" attributes:@{NSForegroundColorAttributeName: color}]; 第二种 [_userName setValue:[UIColor whiteColor] forKeyPath:@"_

C/C++ 修改控制台程序文字颜色

可以修改前景色(字体颜色)和背景色. 示例代码如下: #include <iostream> #include <Windows.h> //需要引用Windows.h using namespace std; int _tmain(int argc, _TCHAR* argv[]) { HANDLE hConsole; hConsole = GetStdHandle(STD_OUTPUT_HANDLE); for(int i=255;i>=0;i--) { SetConsol

shell脚本显示字体颜色

shell脚本中echo显示内容带颜色显示,echo显示带颜色,需要使用参数-e  格式如下:  echo -e "\033[字背景颜色:文字颜色m字符串\033[0m"  例如:  echo -e "\033[41;36m something here \033[0m"  其中41的位置代表底色, 36的位置是代表字的颜色 注:  1.字背景颜色和文字颜色之间是英文的""  2.文字颜色后面有个m  3.字符串前后可以没有空格,如果有的话,输出

使用selector修改TextView中字体的颜色

selector想必大家都用过了,但是在修改字体的颜色的时候还是要细心. 我们在TextView中设置字体颜色一般使用 android:textColor="@color/red" 但是我们在使用selector动态修改字体颜色的时候要使用 [html] view plaincopy android:color="@color/red" 我遇到这个问题的时候是在TabActivity中,每个Tab在选中的时候修改为蓝色. tab_item.xml的代码如下: [ht

修改delphi xe6 FMX Label字体颜色

delphi fmx的字体等设置默认与皮肤有关,用代码直接修改字体颜色等是无效的,如何才能用代码修改呢?请按以下方法就可以: 1.在Object inspector中取消StlyedSettings中的Fontcolor选项的勾. 2.  Label6.TextSettings.FontColor:=TAlphaColors.Red; 也可以直接写代码代替步骤1: Label6.StyledSetings:=[]; Label6.TextSettings.FontColor:=TAlphaCol

echarts各种字体颜色修改

这篇文章主要讲述Echarts设置字体和线条的颜色相关操作笔记,希望文章对你有所帮助,主要是自己的在线笔记吧.我在前面先放各种修改前后图片颜色的对照,后面再详细介绍代码.这样更方便阅读及读者知道,是否对自己有所帮助,其重点是如何在模板动态网页或JSP网站中插入Echarts图片.        1.修改标题及背景颜色    2.设置柱形图颜色 3.修改坐标轴字体颜色        4.设置Legend颜色 5.修改折线颜色    6.修改油表盘字体大小及颜色 7.柱状图文本鼠标浮动上的颜色设置

修改提示框字体及颜色

1.实例介绍 本文使用tooltip控件的draw事件重绘,修改提示框字体及颜色.创建一个winform项目,在一窗体上添加button控件和tooltip控件. 2.实现代码 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using Syst

李洪强iOS开发之-修改状态栏的字体的颜色

李洪强iOS开发之-修改状态栏的字体的颜色 修改的效果: -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [_magicController.view setFrame:CGRectMake(0, 0, CFScreenW, self.view.height-120)]; if ([UIApplication sharedApplication].statusBarStyle != UIStatusBar