欢迎使用CSDN-markdown编辑器

  UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 70, 300, 200)];
    label.numberOfLines = 0;
    label.backgroundColor = [UIColor colorWithRed:235/255.0 green:235/255.0 blue:235/255.0 alpha:1];
    
//——
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@”1321313123211273127318273819273817381738713712837173812731837128371297319737131719371273187328193721731793\n”];
    
    //设置字体颜色
    [text addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, text.length)];
    
    //设置缩进、行距
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    style.headIndent = 30;//缩进
    style.firstLineHeadIndent = 0;
    style.lineSpacing = 10;//行距
    [text addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)];
//——
    
    
    
//——
    NSMutableAttributedString *text2 = [[NSMutableAttributedString alloc] initWithString:@”eqeqeuqoeuquequeqeqwuequeqoueqowueqoueqoshfkahfksdafhkalhfkdshf”];
    //设置字体颜色
    [text2 addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0, text2.length)];
    
    //设置缩进、行距
    NSMutableParagraphStyle *style2 = [[NSMutableParagraphStyle alloc] init];
    style2.headIndent = 0;
    style2.firstLineHeadIndent = 20;
    style2.lineSpacing = 5;
    [text2 addAttribute:NSParagraphStyleAttributeName value:style2 range:NSMakeRange(0, text2.length)];
//——
    
    [text appendAttributedString:text2];
    
    label.attributedText = text;
    [self.view addSubview:label];

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值