zoukankan      html  css  js  c++  java
  • iOS开发 给Label加下划线、中划线

    添加中划线:  

    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];
  • 相关阅读:
    Vue基础简介
    Vue基础简介
    django生命周期请求l流程图
    CSRF与auth模块
    cookie与session django中间件
    Django forms组件与钩子函数
    ajax结合sweetalert实现删除按钮动态效果
    ajax数据交互
    如何绕过CDN找源站ip
    IP地址的另一种形式---一种隐藏IP的方法
  • 原文地址:https://www.cnblogs.com/-ios/p/5818889.html
Copyright © 2011-2022 走看看