iOS给UILabel设置内边距

    NSMutableParagraphStyle *style =  [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    style.alignment = NSTextAlignmentJustified;
    style.firstLineHeadIndent = 10.0f;
    style.headIndent = 10.0f;
    style.tailIndent = -10.0f;

    NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:@"" attributes:@{ NSParagraphStyleAttributeName : style}];
     
    self.contentLbl.numberOfLines = 0;
    self.contentLbl.attributedText = attrText;

你可能感兴趣的:(iOS开发笔记)