NSMutableAttributedString 富文本删除线的用法

 

 

#import <UIKit/UIKit.h>


    //价格
    NSString *priceStr = @"99元 剁手价66元";
    NSMutableAttributedString *priceString = [[NSMutableAttributedString alloc] initWithString:priceStr];
    [priceString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0f] range:NSMakeRange(0, 3)];
    [priceString addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, 3)];
    [priceString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0f] range:NSMakeRange(4, 5)];
    [priceString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithNumber:110] range:NSMakeRange(4, 5)];
    priceLabel.attributedText = priceString;

 

posted @ 2015-07-15 15:35  lear  阅读(460)  评论(0编辑  收藏  举报