您的位置:首页 > 产品设计 > UI/UE

ios UILabel 添加删除线或者下滑线

2016-06-01 15:13 1456 查看
//添加删除线
UILabel  *strLabel = [[UILabel alloc] initWithFrame:(CGRectMake(10, 10, 120, 30))];
NSString *textStr = [NSString stringWithFormat:@"从现在开始"];

NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:textStr attributes:attribtDic];

strLabel.attributedText = attribtStr;
[self.view addSubview:strLabel];


//添加下划线
UILabel *strLabel = [[UILabel alloc] initWithFrame:(CGRectMake(10, 10, 120, 30))];
NSString *textStr = [NSString stringWithFormat:@"坚持就是信仰"];

NSDictionary *attribtDiction = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtString = [[NSMutableAttributedString alloc] initWithString:textStr attributes:attribtDiction];

strLabel.attributedText = attribtString;
[self.view addSubview:strLabel];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: