更改uitextview超链接颜色
我正在使用UITextView
,我想改变我在这个组件中使用的超链接的颜色。 例如,如果UITextView
显示www.gmail.com,则显示为蓝色。 我想改变这种颜色。
简单的答案是你不能做到这一点。
这是一个解决方法,但:
我可以更改UITextView上自动检测链接的颜色吗?
好哇! 苹果已经发布了适合iOS7的解决scheme! 正如在这个答案中所解释的,你可以使用UITextView
的linkTextAttributes
属性。 一个白色的带下划线的链接看起来像这样:
yourTextView.linkTextAttributes = @{ NSForegroundColorAttributeName: [UIColor whiteColor], NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle] };
或者您也可以更改tintColor
,因为UITextView
从UIView
inheritance并使用tintColor
属性为链接着色 – 请参阅:
yourTextView.tintColor = [UIColor whiteColor];
现在你的链接可以看起来史诗!