在iOS中将链接颜色设置为黑色 [英] set Link color to black in iOS

查看:224
本文介绍了在iOS中将链接颜色设置为黑色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS开发的新手(虽然我是自2年以来的网络开发人员)

I am newbie for iOS development (though I am web developer since last 2 years)

我使用TextView在屏幕上创建了一个链接,并提供了黑色。但是,当我运行我的应用程序时,我看到链接颜色为蓝色。知道如何将链接颜色设置为BLACK吗?

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?

是否有类似于iOS开发的CSS?

Is there anything like CSS for iOS development?

推荐答案

您可以在 UIWebView 中轻松设置文本格式,如下所示:

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];  

有关详细信息,我建议您使用官方 UIWebView UIWebViewDelegate 文件。

For more details, i recommend you the official UIWebView and UIWebViewDelegate documentations.

编辑:

@Fahim Parker:

@Fahim Parker:

雅虎链接不会被调用,因为 baseURL 设置为 nil ,你有更好的选择:创建一个html文件, myFile.html ,将其包含在您的Xcode项目中,并将您的代码更改为:

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];

这篇关于在iOS中将链接颜色设置为黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆