码迷,mamicode.com
首页 > 其他好文 > 详细

用NSAttributedString画下划线

时间:2015-07-09 14:51:32      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:下划线

UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(20, 60, 100, 30)];

    [self.view addSubview:lable];

    lable.backgroundColor = [UIColor redColor];

    lable.textAlignment = NSTextAlignmentCenter;

    NSString *oldPrice = @"¥ 999999";

    NSUInteger length = [oldPrice length];

    [self.view addSubview:lable];

    

    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:oldPrice];

    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, length)];

    [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(0, length)];

    [lable setAttributedText:attri];

用NSAttributedString画下划线

标签:下划线

原文地址:http://5828666.blog.51cto.com/5818666/1672486

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!