10

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

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

enter image description here

Cœur
  • 34,719
  • 24
  • 185
  • 251
Y2theZ
  • 9,562
  • 35
  • 125
  • 196

3 Answers3

2

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

UILabel *label = [UILabel alloc] init];
label.textAligment = NSTextAlignmentJustified;
Doro
  • 2,403
  • 2
  • 13
  • 25
1

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.

DivineDesert
  • 6,938
  • 1
  • 28
  • 61
0

Use TTTAttributedLabel NSAtributedString label which has UITextAlignmentJustify

 yourTTTAttributedLabel.textAlignment = UITextAlignmentJustify; 

Also another alternative is use OHAttributedLabel NSAtributedString label which has UITextAlignmentJustify

 yourOHAttributedLabel.textAlignment = UITextAlignmentJustify; 
Paresh Navadiya
  • 37,791
  • 11
  • 79
  • 130