NSMutableAttributedString *attrString =
[[NSMutableAttributedStringalloc] initWithString:@"aaaaaaaa"];
[attrString
addAttribute:NSStrikethroughStyleAttributeNamevalue:[NSNumbernumberWithInteger:NSUnderlinePatternSolid |
NSUnderlineStyleSingle] range:NSMakeRange(0, 3)];
resultTextField.attributedText = attrString;
这样resultTextField显示的前三个a就会使带有中划线的
如下图所示:
改变字体大小
[attrString addAttribute:NSFontAttributeName value:baseFont2
range:NSMakeRange(0, 1)];
改变颜色
[attrString addAttribute:(NSString *)NSForegroundColorAttributeName
value:(id)[UIColor greenColor].CGColor
range:NSMakeRange(0, 1)];
时间: 2024-11-07 00:16:52