UILabel paragraph text alignement

Asked by At

I am working on an Iphone application and I need to display a large text. I need it to have a paragraph alignement. Please refer to the picture below for explanation.

I tried to use UILabel and UITextView but couldn't find the property to do it.

Thanks for any help.

enter image description here

3 Answers

Paresh Navadiya On Best Solutions

Use TTTAttributedLabel NSAtributedString label which has UITextAlignmentJustify

 yourTTTAttributedLabel.textAlignment = UITextAlignmentJustify; 

Also another alternative is use OHAttributedLabel NSAtributedString label which has UITextAlignmentJustify

 yourOHAttributedLabel.textAlignment = UITextAlignmentJustify; 
DivineDesert On

UITextView and UILabel they dont provide such alignment. You can use UIWebview instead.

You can use <p style="text-align:justify">Your text goes here.</p>

This might be helpful.

Doro On

For ios > 7.1 just set textAligment property to NSTextAlignmentJustified , without any third-part libraries:

UILabel *label = [UILabel alloc] init];
label.textAligment = NSTextAlignmentJustified;