iOS开发 给Label加下划线、中划线

添加下划线:

NSString *originPrice = [@"¥" stringByAppendingString:@"100"];

    // 下划线

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

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



    _mBabyPriceHintLb.attributedText = attribtStr;



添加中划线:

 NSString *originPrice = [@"¥" stringByAppendingString:@"100"];

//中划线

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

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


    _mBabyPriceHintLb.attributedText = attribtStr;

你可能感兴趣的:(iOS)