问题
I want to add an image in start of UILabel. Label is multiline. If I use contentInset, it indent the whole label but I want to indent first line only.
I have tried this so far, this doesn't work for me.
UIEdgeInsets titleInsets = UIEdgeInsetsMake(0.0, 40.0, 0.0, 0.0);
valueLabel.contentInset = titleInsets;
It should look like this.

回答1:
@DavidCaunt suggestion worked for me. I am sharing code here.
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
style.firstLineHeadIndent = 50;
[attributedText addAttribute:NSParagraphStyleAttributeName value:style range:range];
[valueLabel setAttributedText:attributedText];
回答2:
As a user716216 pointed, additionally - we can use a tab with defined indent value:
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.headIndent = 50;
label.attributedText = [[NSAttributedString alloc] initWithString:
@"\tHow can i add image like this in start of UILabel? Label is multiline.........."
attributes:@{NSParagraphStyleAttributeName: paragraphStyle}];
回答3:
Here's how you can do this in Interface Builder:
来源:https://stackoverflow.com/questions/21430685/how-can-i-indent-only-first-line-of-multiline-uilabel-in-ios