In my application, i have a UITextView
with many lines, but I need the data with proper appearance.
Is it possible to have Justified Alignment in UITextView
?
When you justify text, space is added between words so that both edges of each line are aligned with both margins. The last line in the paragraph is aligned left. Click anywhere in the paragraph that you want to justify. On the Home tab, in the Paragraph group, click Justify Text .
I know it's an old question but now we have news about :
UITextView *textView = // init your text view textView.textAlignment = NSTextAlignmentJustified;
And that's it !
UPDATE: This only works on iOS 6 and above
I have come to a solution that works. First of all, you will need to change your UITextView and use a UIWebView
instead.
Details.h
@interface Details : UIViewController {
IBOutlet UIWebView *descripcion;
}
@property (nonatomic, retain) UIWebView *descripcion;
Then, load your UIWebView
as follows:
Details.m
[descripcion loadHTMLString:[NSString stringWithFormat:@"<div align='justify'>%@<div>",YOUR_TEXT] baseURL:nil];
There is solution:
NSString *text1 = @"Sample text : A his is my weblog in English, German and Korean. If you want to know more about a pizza stone once it’s cooled down.";
NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[style setAlignment: kCTJustifiedTextAlignment];
NSAttributedString * subText1 = [[NSAttributedString alloc] initWithString:text1 attributes:@{
NSParagraphStyleAttributeName : style
}];
_myUiTextView.attributedText = subText1;
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