views:

914

answers:

4

I had a UITextView that detects phone numbers ans links, but this overrides my fontColor and change it to blueColor. Is there a way to format the color of auto detected links, or should I try a manual version of this function?

A: 

Anyone have an answer to this? I can't imagine that you can change the overall font color but not the auto-detected link font color. I've got light colored text on a dark background and the blue link color does not have enough contrast.

Thanks!

Jeff
Instead of using an UITextView, I used an UIWebView and enabled the "auto-detect links". To change the link color, just created a regular CSS for the <a> tag.
+3  A: 

Instead of using an UITextView, I used an UIWebView and enabled the "auto-detect links". To change the link color, just created a regular CSS for the tag.

I used something like this:

NSString * htmlString = [NSString stringWithFormat:@"<html><head><script> document.ontouchmove = function(event) { if (document.body.scrollHeight == document.body.clientHeight) event.preventDefault(); } </script><style type='text/css'>* { margin:0; padding:0; } p { color:black; font-family:Helvetica; font-size:14px; } a { color:#63B604; text-decoration:none; }</style></head><body><p>%@</p></body></html>", [update objectForKey:@"text"]];
webText.delegate = self;
[webText loadHTMLString:htmlString baseURL:nil];
A: 

Anyone managed to do that without using a UIWEBVIEW ?

The way I did is added to the answer.
+1  A: 

you need to make a stylesheet for that. Define a class there with the color combination you need-

.headercopy {
 font-family: "Helvetica";
 font-size: 14px;
 line-height: 18px;
 font-weight:bold;
 color: #25526e;
}
a.headercopy:link {
 color:#ffffff;
 text-decoration:none;
}
a.headercopy:hover {
 color:#00759B;
 text-decoration:none;
}
a.headercopy:visited {
 color:#ffffff;
 text-decoration:none;
} 
a.headercopy:hover {
 color:#00759B;
 text-decoration:none;
}

now use the class 'headercopy' into you html page like this-

<b>Fax:</b><a href="tel:646.200.7535" class="headercopy"> 646-200-7535</a><br />

this will display the phone number in the color you need with click functionality.

Vaibhav Saran