/**
*@param NSFontAttributeName文字大小
*@param NSForegroundColorAttributeName文字颜色
*@param NSStrikethroughColorAttributeName删除线的颜色
*@param NSStrikethroughStyleAttributeName删除线样式
*/
UILabel *priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 30)];
priceLabel.text = @"500元";
priceLabel.backgroundColor = [UIColor yellowColor];
NSAttributedString *attrStr=[[NSAttributedString alloc]initWithString:priceLabel.text attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor grayColor],NSStrikethroughColorAttributeName:[UIColor grayColor],NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle|NSUnderlinePatternSolid)}];
priceLabel.attributedText = attrStr;
[self.view addSubview:priceLabel];
UILabel文字添加删除线
最新推荐文章于 2021-11-14 14:22:00 发布