码迷,mamicode.com
首页 > 其他好文 > 详细

NSMutableAttributedString 的使用方法,设置格式

时间:2014-05-19 11:20:27      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   c   java   

bubuko.com,布布扣
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:title];
    NSRange range = NSMakeRange(0, [attrString length]);
    
    [attrString beginEditing];
    [attrString addAttribute:NSLinkAttributeName value:aURL range:range];
    
    // make the text appear in blue
    [attrString addAttribute:NSForegroundColorAttributeName value:[NSColor blueColor] range:range];
    
    // next make the text appear with an underline
    [attrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSSingleUnderlineStyle] range:range];
    
    // allow truncation
    NSMutableParagraphStyle *ps = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    [ps setLineBreakMode:NSLineBreakByTruncatingTail];
    [attrString addAttribute:NSParagraphStyleAttributeName value:ps range:range];
    [ps release];
    
    [attrString endEditing];
    
    return [attrString autorelease];    
bubuko.com,布布扣

转载自:http://blog.csdn.net/ch_soft/article/details/6877508

NSMutableAttributedString 的使用方法,设置格式,布布扣,bubuko.com

NSMutableAttributedString 的使用方法,设置格式

标签:style   blog   class   code   c   java   

原文地址:http://www.cnblogs.com/benbenzhu/p/3731797.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!