NSMutableAttributedString添加删除线(中划线)

时间:2014-05-09 04:22:49   收藏:0   阅读:287

NSMutableAttributedString *attrString = [[NSMutableAttributedStringalloc] initWithString:@"aaaaaaaa"];

    [attrString addAttribute:NSStrikethroughStyleAttributeNamevalue:[NSNumbernumberWithInteger:NSUnderlinePatternSolid | NSUnderlineStyleSingle] range:NSMakeRange(0, 3)];

  resultTextField.attributedText = attrString;

这样resultTextField显示的前三个a就会使带有中划线的

如下图所示:

bubuko.com,布布扣

改变字体大小

[attrString addAttribute:NSFontAttributeName value:baseFont2

                           range:NSMakeRange(0, 1)];

 

改变颜色

[attrString addAttribute:(NSString *)NSForegroundColorAttributeName

                           value:(id)[UIColor greenColor].CGColor

                           range:NSMakeRange(0, 1)];

NSMutableAttributedString添加删除线(中划线),布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!