I am newbie for iOS development (though I am web developer since last 2 years)
I have created a link on my screen using TextView and provided color as black. However when I run my application I see link color as BLUE. Any idea how to make link color to BLACK?
Is there anything like CSS for iOS development?
You can easily format text within UIWebView
, something like below:
NSString *pureHtmlText = [NSString stringWithFormat:@"<html><head><STYLE
type=text/css>body{margin-top:1cm;}</STYLE></head><body style=background-color:
transparent;><br /><p><font face=heveltica neue; size=5>Other text: </font></p></body></html>"];
//Load text in UIWebView (don't forget to declare a UIWebView instance for sure)
[webView loadHTMLString:pureHtmlText baseURL:nil];
For more details, i recommend you the official UIWebView and UIWebViewDelegate documentations.
EDIT:
@Fahim Parker:
Yahoo link will not gets called because baseURL
is set to nil
, you have better option: create a html file, myFile.html
, include it into your Xcode project, and change your code to something like:
NSBundle *myBundle = [NSBundle mainBundle];
NSString *path = [myBundle pathForResource:@"myFile" ofType:@"html"];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[self.webView loadHTMLString:@"myFile.html" baseURL:baseURL];
Automatic recognition links in UITextView
always show up blue, unless you subclass and customize it. You can use UIWebView
to display some styled HTML content though.