Change color of UITextView links with a filter?

前端 未结 3 1514
你的背包
你的背包 2021-01-06 14:19

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?<

3条回答
  •  悲哀的现实
    2021-01-06 15:05

    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.

提交回复
热议问题