zoukankan      html  css  js  c++  java
  • iOS -多字体混合

    label 加下划线

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 300, 100)];
        label.backgroundColor = [UIColor redColor];
        label.numberOfLines = 3;
        NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"您的待办业务条fasdfasdfosadfjasdkljfklasjklfjasdlkjfklasdjklfjalskdjflkadsj"]];
        NSRange contentRange = {0,[content length]};
        [content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
        
        label.attributedText = content;
        [self.view addSubview:label];

    设置  大小不同的字体

           NSString * stra = [NSString stringWithFormat:@"0 %.2lf 0",[straaa doubleValue]];

                    NSMutableAttributedString * str = [[NSMutableAttributedString alloc] initWithString:stra];

                    [str addAttribute:NSFontAttributeName value: kFontSize_24 range:NSMakeRange(0, 2)];

                    [str addAttribute:NSFontAttributeName value: kFontSize_100 range:NSMakeRange(2, str.length - 4)];

                    [str addAttribute:NSFontAttributeName value: kFontSize_24 range:NSMakeRange(str.length - 2, 2)];

                    [str addAttribute:NSForegroundColorAttributeName value: kColorBackground range:NSMakeRange(str.length - 2, 2)];

                    lable1.attributedText = str;

  • 相关阅读:
    react组件之间传值方式
    html url 传递锚点并添加参数
    Spring Boot 构建WAR包
    Spring Boot Actuator 的使用
    Spring boot的启动加载原理
    intellij idea resin容器部署web工程
    Mybatis Mapper之见解
    踩坑----数据库阻塞
    redis缓存与数据库的记录不一致造成的问题.(乐观锁)
    H5中popstate事件的诡异行为
  • 原文地址:https://www.cnblogs.com/isItOk/p/5334356.html
Copyright © 2011-2022 走看看