【发布时间】:2017-11-22 22:53:20
【问题描述】:
我正在使用UITextView,并且我想更改我在此组件中使用的超链接的颜色。例如,如果 UITextView 显示 www.gmail.com,则它显示为蓝色。我想改变那个颜色。
【问题讨论】:
标签: ios uitextview
我正在使用UITextView,并且我想更改我在此组件中使用的超链接的颜色。例如,如果 UITextView 显示 www.gmail.com,则它显示为蓝色。我想改变那个颜色。
【问题讨论】:
标签: ios uitextview
嘘! Apple 已经发布了适用于 iOS7 的解决方案!如this answer 中所述,您可以使用UITextView 的linkTextAttributes 属性。带下划线的白色链接如下所示:
yourTextView.linkTextAttributes = @{
NSForegroundColorAttributeName: [UIColor whiteColor],
NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle]
};
或者您也可以更改tintColor,因为UITextView 继承自UIView 并使用tintColor 属性为链接着色 - 请参阅:
yourTextView.tintColor = [UIColor whiteColor];
现在您的链接看起来很棒!
【讨论】:
【讨论】: