关闭

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

106人阅读 评论(0) 收藏 举报
分类:
//添加删除线
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];


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:4909次
    • 积分:317
    • 等级:
    • 排名:千里之外
    • 原创:28篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类