Sian 发表于 2014-7-14 09:36:53

富文本(NSMutableAttributedString)的使用

1、创建对象

  NSString *original = @"今天你还好吗?";

  NSMutableAttributedString *attrTitle = [ initWithString:original];

2、设置颜色(NSForegroundColorAttributeName代表要设置颜色, value代表值, range 代表范围)

  /**

    其他设置:

      1.NSForegroundColorAttributeName //颜色

      2.NSFontAttributeName //字体

      3.NSBackgroundColorAttributeName //背景色

     //还有其他的很多的属性,可以自己去看苹果的API,这里不再详述

  */

   range:NSMakeRange(0, 2)];

3、添加到Label中

    UILabel *label = [ init];

    label.frame = CGRectMake(100, 100, 100, 40);

    ;

    ;

参考链接:http://www.cnblogs.com/d2688/p/3622344.html
页: [1]
查看完整版本: 富文本(NSMutableAttributedString)的使用