添加中划线:
0
1
02
03
04
05
06
07
08
09
10
11
|
UILabel * strikeLabel = [[UILabel alloc] initWithFrame:(CGRectMake(10, 10, 50, 30))];
NSString
*textStr = [
NSString
stringWithFormat:
@"%@元"
, primeCost];
//中划线
NSDictionary
*attribtDic = @{
NSStrikethroughStyleAttributeName
: [
NSNumber
numberWithInteger:
NSUnderlineStyleSingle
]};
NSMutableAttributedString
*attribtStr = [[
NSMutableAttributedString
alloc]initWithString:textStr attributes:attribtDic];
// 赋值
strikeLabel.attributedText = attribtStr;
[
self
.view addSubview:strikeLabel];
|
01
02
03
04
05
06
07
08
09
10
11
|
UILabel *underlineLabel = [[UILabel alloc] initWithFrame:(CGRectMake(10, 10, 50, 30))];
NSString
*textStr = [
NSString
stringWithFormat:
@"%@元"
, primeCost];
// 下划线
NSDictionary
*attribtDic = @{
NSUnderlineStyleAttributeName
: [
NSNumber
numberWithInteger:
NSUnderlineStyleSingle
]};
NSMutableAttributedString
*attribtStr = [[
NSMutableAttributedString
alloc]initWithString:textStr attributes:attribtDic];
//赋值
underlineLabel.attributedText = attribtStr;
[
self
.view addSubview:underlineLabel];
|