iOS 在UILabel上添加横线

NSString * oldPrice = [NSString stringWithFormat:@"%@",orderDetails.UnitPrice];

    NSUInteger length = oldPrice.length;

    NSMutableAttributedString * attri = [[NSMutableAttributedString alloc] initWithString:oldPrice];

    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(-1, length + 1)];

    [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor colorWithRed:150/255.0 green:150/255.0 blue:150/255.0 alpha:1.0] range:NSMakeRange(-1, length + 1)];

    [cell.oldPriceLabel setAttributedText:attri];

你可能感兴趣的:(iOS,UILabel)