标签:
有一些控件无法直接设置文本大小,需要使用方法 setTitleTextAttributes 来设置文本属性
UIFont 字体样式 [UIFont fontWithName~];
UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:@"任务" style:UIBarButtonItemStylePlain target:self action:@selector(clickRightBarItem)]; [rightBarItem setTintColor:[UIColor blackColor]]; [rightBarItem setTitleTextAttributes:@{ //1.设置字体样式:例如黑体,和字体大小 NSFontAttributeName:[UIFont fontWithName:@"Arial-BoldMT" size:15], //2.设置段落样式 NSParagraphStyleAttributeName:[NSParagraphStyle defaultParagraphStyle], //3.设置文字颜色 NSForegroundColorAttributeName:[UIColor redColor], //4.设置背景颜色 NSBackgroundColorAttributeName:[UIColor greenColor] }forState:(UIControlStateNormal)];
Attributes:文本属性 和NSAttributedString
标签:
原文地址:http://www.cnblogs.com/jiayongqiang/p/5570746.html