UILabel 中划线实效

因为有中文所以 中线无效
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

推荐阅读更多精彩内容