当前位置:   article > 正文

label 字体添加中划线和下划线_yylabel 设置中划线

yylabel 设置中划线

中划线

  1. UILabel * strikeLabel = [[UILabel alloc] initWithFrame:(CGRectMake(10, 10, 50, 30))];
  2. NSString *textStr = [NSString stringWithFormat:@"%@元", primeCost];
  3. //中划线
  4. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  5. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  6. // 赋值
  7. strikeLabel.attributedText = attribtStr;
  8. [self.view addSubview:strikeLabel];

下划线 

  1. UILabel *underlineLabel = [[UILabel alloc] initWithFrame:(CGRectMake(10, 10, 50, 30))];
  2. NSString *textStr = [NSString stringWithFormat:@"%@元", primeCost];
  3. // 下划线
  4. NSDictionary *attribtDic = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  5. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  6. //赋值
  7. underlineLabel.attributedText = attribtStr;
  8. [self.view addSubview:underlineLabel];
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/729102
推荐阅读
相关标签
  

闽ICP备14008679号