-1

Here is the code:-

lblValue is an instance of UILabel.

[lblValue setText:@"Some Big String"];
[lblValue setTextAlignment: NSTextAlignmentJustified];

Error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'textAlignment does not accept NSTextAlignmentJustified'

Burhanuddin Sunelwala
  • 5,318
  • 3
  • 25
  • 51
  • NSTextFieldAlignement works only with iOS6. If you're targeting iOS5 or iOS4.3, it won't work. – Larme Apr 22 '13 at 10:23

1 Answers1

2

If you are using iOS6 then UITextAlignment is deprecated. You can NSAttributedString or you can use some 3rd party attributed Labels with fine alignment for this purpose.

UIKit

NSString drawing additions and UILabel do not support NSTextAlignmentJustified orNSTextAlignmentNatural text alignments. Instead, use NSAttributedString drawing additions, which do support text alignments.

From UILabel Docs

If you are using styled text in iOS 6 or later, assigning a new value to this property causes the text alignment to be applied to the entirety of the string in the attributedText property. If you want to apply the alignment to only a portion of the text, create a new attributed string with the desired style information and associate it with the label. If you are not using styled text, this property applies to the entire text string in the text property.

nsgulliver
  • 12,655
  • 23
  • 43
  • 64