您的当前位置:首页正文

使用NSAttributedString 给UILabel文字添

来源:花图问答

/**

*@param NSFontAttributeName文字大小

*@param NSForegroundColorAttributeName文字颜色

*@param NSStrikethroughColorAttributeName删除线的颜色

*@param NSStrikethroughStyleAttributeName删除线样式

*/

NSAtrributedString*attrStr=[[NSAtrributedStringalloc]initWithString:self.priceLabel.text attributes:@{NSFontAttributeName:[UIFontsystemFontOfSize:12],NSForegroundColorAttributeName:[UIColorredColor],NSStrikethroughColorAttributeName:[UIColorgreenColor],NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle|NSUnderlinePatternSolid)}];

self.priceLabel.attributedText=attrStr;