美文网首页
UILable加中划线

UILable加中划线

作者: f48ac133a97f | 来源:发表于2018-04-09 12:58 被阅读0次

     NSString *priceStr = [NSString stringWithFormat:@"%.2f元",payInfo.originalPrice];

    1、原来添加中划线方式(在iOS10.3系统后失效)

    //    NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};

    //    NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:priceStr attributes:attribtDic];

    2、解决办法

        NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:priceStr];

        [attribtStr setAttributes:@{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle],   NSBaselineOffsetAttributeName : @(NSUnderlineStyleSingle)} range:NSMakeRange(0, priceStr.length)];

    相关文章

      网友评论

          本文标题:UILable加中划线

          本文链接:https://www.haomeiwen.com/subject/rzxihftx.html