美文网首页
UILabel首行缩进

UILabel首行缩进

作者: FengxinLi | 来源:发表于2018-01-12 13:54 被阅读35次

    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 200)];

        titleLabel.text = @"测试首行缩进测试首行缩进测试首行缩进测试首行缩进测试首行缩进测试首行缩进测试首行缩进测试首行缩进";

        titleLabel.numberOfLines = 0;

        NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];

        style.firstLineHeadIndent = 40;

        NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:titleLabel.text];

        [attrString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, 40)];

        titleLabel.attributedText = attrString;

        [self.view addSubview:titleLabel];

    相关文章

      网友评论

          本文标题:UILabel首行缩进

          本文链接:https://www.haomeiwen.com/subject/fvkfoxtx.html