直接上代码
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 100)];
[self.view addSubview:label];
NSAttributedString *attributedString = [[NSAttributedString alloc]initWithString:@"10000¥"
attributes:
@{NSFontAttributeName:[UIFont systemFontOfSize:20.f],//设置字体大小
NSForegroundColorAttributeName:[UIColor greenColor],//设置字体颜色
NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle|NSUnderlinePatternSolid),//设置删除线样式
NSStrikethroughColorAttributeName:[UIColor redColor]}];//设置删除线颜色
label.attributedText = attributedString;
label.font = [UIFont systemFontOfSize:36 weight:50];
效果图
UILabel添加删除线
网友评论