NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Old price"];
[str addAttribute:NSStrikethroughStyleAttributeName
value:@2
range:NSMakeRange(0, [str length])];
如何改变醒目的颜色?
答案 0 :(得分:0)
试试这个
NSDictionary *attrs = @{ NSFontAttributeName:[UIFont systemFontOfSize:12.0f],
NSStrikethroughStyleAttributeName: @(NSUnderlineStyleSingle),
NSStrikethroughColorAttributeName: [UIColor redColor],
NSBackgroundColorAttributeName: [UIColor yellowColor]
};
答案 1 :(得分:0)
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Old price"];
NSRange range = NSMakeRange(0, [str length]);
[str addAttribute:NSStrikethroughStyleAttributeName value:@2 range:range];
[str addAttribute:NSStrikethroughColorAttributeName value:[UIColor greenColor] range:range];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:range];