用过滤器更改UITextView链接的颜色? [英] Change color of UITextView links with a filter?

查看:211
本文介绍了用过滤器更改UITextView链接的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在UITextView上检测到的链接总是蓝色的。没有办法直接改变这一点。但是,我可以覆盖某种过滤器,例如,蓝色变为红色吗?

解决方案

实际上有一种方法可以做到这一点使用私有API
$ b $ UITextView 有一个类(code> UIWebDocumentView setUserStyleSheet:。



以下代码应该将链接的颜色更改为绿色。至少,它为我工作! :)
$ b $ pre $ for(UIView * subview in textView.subviews){
[subview setUserStyleSheet:@a {color :#00FF00;}];
}

我知道这真的很晚,但是几个小时的Google让我没有在哪里,所以我想我会分享这个。


The detected links on a UITextView are always blue. There's no way to directly change this. But can I overlay some sort of filter which changes blue to, for instance, red?

解决方案

There's actually a way to do this with private API.

A UITextView has a (single) subview of class UIWebDocumentView, with the selector setUserStyleSheet:.

The following code should change the color of the links to green. At least, it worked for me! :)

for (UIView *subview in textView.subviews) {
    [subview setUserStyleSheet:@"a { color: #00FF00; }"];
}

I know this is really late, but hours of Googling got me no where, so I thought I'd share this.

这篇关于用过滤器更改UITextView链接的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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