添加中划线:
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #3495af }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; min-height: 16.0px }
span.s1 { }
span.s2 { color: #3495af }
span.s3 { color: #000000 }
span.s4 { color: #b4261a }
span.s5 { font: 14.0px "PingFang SC"; color: #b4261a }
span.s6 { color: #008f00 }
span.s7 { font: 14.0px "PingFang SC"; color: #008f00 }
span.s8 { color: #0433ff }
UILabel * strikeLabel = [[UILabel alloc] initWithFrame:(CGRectMake(10, 10, 50, 30))];
NSString *textStr = [NSString stringWithFormat:@"%@元", @"12"];
//中划线
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
// 赋值
strikeLabel.attributedText = attribtStr;
[self.view addSubview:strikeLabel];
添加下划线:
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #3495af }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; min-height: 16.0px }
span.s1 { }
span.s2 { color: #3495af }
span.s3 { color: #000000 }
span.s4 { color: #b4261a }
span.s5 { font: 14.0px "PingFang SC"; color: #b4261a }
span.s6 { color: #008f00 }
span.s7 { font: 14.0px "PingFang SC"; color: #008f00 }
span.s8 { color: #0433ff }
UILabel *underlineLabel = [[UILabel alloc] initWithFrame:(CGRectMake(10, 10, 50, 30))];
NSString *textStr = [NSString stringWithFormat:@"%@元", @"12"];
// 下划线
NSDictionary *attribtDic = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
//赋值
underlineLabel.attributedText = attribtStr;
[self.view addSubview:underlineLabel];