ios 更改 uitextview 超链接颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13405513/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
change uitextview hyperlink color
提问by Muzamil Hassan
I am using UITextViewand i want to change the color of hyperlink which i use in this component. For example if UITextViewis showing www.gmail.comthen it shows up in blue color. I want to change that color.
我正在使用UITextView并且我想更改我在此组件中使用的超链接的颜色。例如,如果UITextView显示www.gmail.com,则显示为蓝色。我想改变那个颜色。
采纳答案by HackyStack
The simple answer is you cannot do it.
简单的答案是你做不到。
Here's a workaround though:
不过,这里有一个解决方法:
Can I change the color of auto detected links on UITextView?
回答by Tim Windsor Brown
Huzzah! Apple have released a proper solution with iOS7! As explained in this answeryou can use the linkTextAttributesproperty of a UITextView. A white, underlined link would look something like this:
哈扎!苹果在iOS7上发布了一个合适的解决方案!如本答案所述,您可以使用 a 的linkTextAttributes属性UITextView。带有下划线的白色链接如下所示:
yourTextView.linkTextAttributes = @{
NSForegroundColorAttributeName: [UIColor whiteColor],
NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle]
};
or alternatively you could change the tintColor, since UITextViewinherits from UIViewand uses the tintColorproperty to colour links - see:
或者,您可以更改tintColor, 因为UITextView继承自UIView并使用该tintColor属性为链接着色 - 请参阅:
yourTextView.tintColor = [UIColor whiteColor];
Now your links can look epic!
现在您的链接可以看起来像史诗!

