label設置列間距和首行縮進

 NSMutableAttributedString *attributedString = [[NSMutableAttributedStringalloc] initWithString:self.contentLabel.text];spa

    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStylealloc] init];orm

    paragraphStyle.alignment = NSTextAlignmentLeft;ci

    paragraphStyle.maximumLineHeight = 60;  //最大的行高 it

    paragraphStyle.lineSpacing = 5;  //行自定義行高度table

    [paragraphStyle setFirstLineHeadIndent:self.usernameLabel.frame.size.width + 5];//首行縮進 根據用戶暱稱寬度在加5個像素im

    [attributedString addAttribute:NSParagraphStyleAttributeNamevalue:paragraphStyle range:NSMakeRange(0, [self.contentLabel.textlength])];margin

    self.contentLabel.attributedText = attributedString;top

    [self.contentLabelsizeToFit];tab

//self.contentLabel.adjustsLetterSpacingToFitWidth = YES;di

相關文章
相關標籤/搜索