vijay
vijay

Reputation: 1235

how to justify text in UITextView in iphone?

how to justify text in UITextView I try this like this but this code do not give any output.

[web loadHTMLString:[NSString stringWithFormat:
     @"<html><body><p align=\"justify\"> %@ </p> </body></html>",
     [dict1 objectForKey:@"services_description"]] baseURL:nil];

Upvotes: 0

Views: 1411

Answers (4)

Azhar
Azhar

Reputation: 20670

textView.textAlignment = NSTextAlignmentJustified;

This only works on iOS 6 and above

Upvotes: 2

Siba Prasad Hota
Siba Prasad Hota

Reputation: 4789

You can Create a HTML Page with propertext allignment and then Load the Local HTML page in a Webview.

  webView = [UIWebView alloc] init];

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] 
                                pathForResource:@"test" ofType:@"html"]isDirectory:NO]]];

Upvotes: 0

Vishnu Kumar. S
Vishnu Kumar. S

Reputation: 1837

You can justify the text in the UITextView by choosing the alignment from the utilities

Upvotes: 0

Rajneesh071
Rajneesh071

Reputation: 31081

I suggest You to use WebView Because justified aligment for text you only have center, left and right by UITextView.

IF You Want to Use UIWebView then set in

className.h

@interface className : UIViewController {
    IBOutlet UIWebView *webviewName;
}
@property (nonatomic, retain) UIWebView *webviewName;  

className.m

[webviewName loadHTMLString:[NSString stringWithFormat:@"<div align='justify'>%@<div>",TEXT_set] baseURL:nil];

Upvotes: 0

Related Questions