label文字加横线

- (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;
    
}

你可能感兴趣的:(label文字加横线)