label文字加横线

2017-10-12  本文已影响9人  吃货_X
- (void)strikethrouthLineWithLabel:(UILabel *)label {
    NSString *oldPrice = label.text;
    NSUInteger length = [oldPrice length];

    NSMutableAttributedString *attritu = [[NSMutableAttributedString alloc]initWithString:oldPrice];
    [attritu addAttributes:@{
                             NSStrikethroughStyleAttributeName:@(NSUnderlineStyleThick),
                             NSForegroundColorAttributeName:
                                label.textColor,
                             NSBaselineOffsetAttributeName:
                                 @(0),
                             NSFontAttributeName: label.font
                             } range:NSMakeRange(0, length)];
    label.attributedText = attritu;
    
}
上一篇 下一篇

猜你喜欢

热点阅读