首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

NSMutableAttributedString施用

2013-07-20 
NSMutableAttributedString使用NSMutableAttributedString *attriString [[NSMutableAttributedString a

NSMutableAttributedString使用
NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:@"范例范例范例范例范例范例范例范例范例范例"];
   
   
    [attriString addAttribute:(NSString *)kCTForegroundColorAttributeName
                        value:(id)[UIColor redColor].CGColor
                        range:NSMakeRange(3, 4)];
   
    NSUInteger length = [attriString length];
    //添加字体目标字符串从下标0开始到字符串结尾
    UIFont *baseFont = [UIFont systemFontOfSize:17.0];
    [attriString addAttribute:NSFontAttributeName value:baseFont
                       range:NSMakeRange(0, length)];
  
   
    CATextLayer *textLayer = [CATextLayer layer];
    textLayer.string = attriString;
    textLayer.frame = CGRectMake(47, 12, 226, 56);
    [self.view.layer addSublayer:textLayer];

热点排行