我正在使用 UITextView
,想要改变在此组件中使用的超链接颜色。例如,如果 UITextView
显示www.gmail.com,则以蓝色显示。我想改变这种颜色。
我正在使用 UITextView
,想要改变在此组件中使用的超链接颜色。例如,如果 UITextView
显示www.gmail.com,则以蓝色显示。我想改变这种颜色。
哎呀!苹果在iOS7中发布了一个合适的解决方案!如这个答案所解释的那样,您可以使用UITextView
的linkTextAttributes
属性。 白色下划线链接将看起来像这样:
yourTextView.linkTextAttributes = @{
NSForegroundColorAttributeName: [UIColor whiteColor],
NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle]
};
或者您可以更改tintColor
,因为UITextView
继承自UIView
并使用tintColor
属性来着色链接 - 请参见:
或者您可以更改tintColor
,因为UITextView
继承自UIView
并使用tintColor
属性来着色链接 - 请参见:
yourTextView.tintColor = [UIColor whiteColor];
现在你的链接可以看起来很棒!