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
  • 37,241
  • 25
  • 195
  • 267
Y2theZ
  • 10,162
  • 38
  • 131
  • 200

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,413
  • 2
  • 14
  • 26
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,924
  • 1
  • 29
  • 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
  • 38,095
  • 11
  • 81
  • 132