• 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;

  • 相关阅读:
    【洛谷P3901】数列找不同
    【洛谷P2966】Cow Toll Paths
    【CH6901】骑士放置
    【洛谷P2215】上升序列
    【洛谷P1637】三元上升子序列
    【POJ2226】Muddy Fields
    【UVA1194】Machine Schedule
    【CH6803】导弹防御塔
    【CH6802】车的放置
    hdu 3572(构图+最大流)
  • 原文地址:https://www.cnblogs.com/isItOk/p/5334356.html
Copyright © 2020-2023  润新知