UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(20, 50, 200, 50)];
[self.view addSubview:label];
label.text = @"24.56";
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor redColor];
NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"¥%@",label.text]];
[attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, attri.length)];// 如果不加这个,横线的颜色跟随label字体颜色改变
[attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor grayColor] range:NSMakeRange(0, attri.length)];
label.attributedText = attri;
[self.view addSubview:label];
label.text = @"24.56";
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor redColor];
NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"¥%@",label.text]];
[attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, attri.length)];// 如果不加这个,横线的颜色跟随label字体颜色改变
[attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor grayColor] range:NSMakeRange(0, attri.length)];
label.attributedText = attri;
显示效果如下: