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];
  • 相关阅读:
    python并发编程之IO模型
    协程与concurent.furtrue实现线程池与进程池
    网络编程之线程进阶
    多线程讲解
    网络编程之进阶2
    网络编程之进阶
    网络编程之进程
    函数复习之2
    函数复习
    深克隆和浅克隆
  • 原文地址:https://www.cnblogs.com/-ios/p/5818889.html
Copyright © 2011-2022 走看看