1.按钮
btn.titleLabel.font = [UIFont systemFontOfSize:15.0]
2.导航条
如何要统一设置整个应用程序的导航条上的文字,就自定义一个导航控制器,然后重写load方法
+(void)load
{
UINavigationBar *navBar = [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[self]];
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
dic[NSFontAttributeName] = [UIFont boldSystemFontOfSize:20.0];
[navBar setTitleTextAttributes:dic];
}
如果是在某一个控制器中设置它导航条上的标题文字
[self.navigationController.navigatonBar setTitltTextAttributes:]
注意是对导航条navigationBar进行setTitleText
3.tabBar
一般统一设置,分两种状态
注意是对tabBarItem进行setTitleText
+(void)load
{
UITabBarItem *tabBarItem = [UITabBarItem appearanceWhenContainedInInstancesOfClasses:@[self]];
//选中状态
NSMutableDictionary *textColorDic = [NSMutableDictionary dictionary];
textColorDic[NSForegroundColorAttributeName] = [UIColor blackColor];
[tabBarItemsetTitleTextAttributes:textColorDic forState:UIControlStateSelected];
//正常状态
NSMutableDictionary *textSizeDic = [NSMutableDictionary dictionary];
textSizeDic[NSFontAttributeName] = [UIFontsystemFontOfSize:13.0];
[tabBarItemsetTitleTextAttributes:textSizeDic forState:UIControlStateNormal];
}
4.label
直接label.font
可以拿到label子控件的,直接拿到label的font属性,进行设置,其余的进行setTitleText