I am use Xcode4.5 and iOS6 now, the iOS6 have change the UILable's textAlignment,
label.textAlignment = NSTextAlignmentJustified;
The code will crash on iPhone 6.0 Simulator with ios6 SDK. but not crash on iPhone 5.0 Simulator with iOS6 SDK.
The iOS6 support NSTextAlignmentJustified, but why will crash?
Edit 1:
Using NSAttributedString
we can justify text.
NSMutableParagraphStyle *paragraphStyles = [[NSMutableParagraphStyle alloc] init];
paragraphStyles.alignment = NSTextAlignmentJustified;
paragraphStyles.firstLineHeadIndent = 0.05; // Very IMP
NSString *stringTojustify = @"We are what our thoughts have made us; so take care about what you think. Words are secondary. Thoughts live; they travel far.";
NSDictionary *attributes = @{NSParagraphStyleAttributeName: paragraphStyles};
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:stringTojustify attributes:attributes];
self.lblQuote.attributedText = attributedString;
self.lblQuote.numberOfLines = 0;
[self.lblQuote sizeToFit];
Deprecation of UITextAlignmentJustify
, not available anymore under iOS 6.
All possible solutions to justified text are given at this SO link also have a look at this page and iOS6 prerelease Documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With