NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle],NSStrikethroughColorAttributeName:[UIColor orangeColor]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:@"原¥1000" attributes:attribtDic];
self.myLabel.attributedText = attribtStr;
去掉字符串中的‘原’,就能显示了
很奇怪,为什么没有中文就能显示,但‘¥’是在中文环境下打出来的,为什么要显示如果有中文文子怎么呢?
//看有哪里不一样
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle],NSBaselineOffsetAttributeName : @(NSUnderlineStyleSingle),NSStrikethroughColorAttributeName:[UIColor orangeColor]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:@"原来如此¥1000" attributes:attribtDic];
self.myLabel.attributedText = attribtStr;
成功!
参考:http://blog.csdn.net/ymh1989qwe/article/details/70954275?utm_source=itdadao&utm_medium=referral
网友评论