首页 > 其他 > 详细

Attributes:文本属性 和NSAttributedString

时间:2016-06-08 18:57:16      阅读:182      评论:0      收藏:0      [点我收藏+]

前言:

  有一些控件无法直接设置文本大小,需要使用方法 setTitleTextAttributes 来设置文本属性

 

UIFont 字体样式 [UIFont fontWithName~];

iOS- 详解文本属性Attributes - 清澈Saup - 推酷

 

    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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!