Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of UITextview UIDataDetectorTypeLink?

  1. I am passing some urls to the UITextView and they are detected using UIDataDetectorTypeLink. Now I'm in need to change the color of the link(url) to some uicolor. I have no idea on how to do this.

    Here is the code showing my attempt:

    [textview_Url setEditable:NO];
    [textview_Url setScrollEnabled:NO];
    [textview_Url setDataDetectorTypes:UIDataDetectorTypeLink];
    [textview_Url setText:web];

    It gives blue, and I want to change that color.

  2. By UIDataDetectorTypeLink, a long press only asks conformation to redirect to the link. But I want to show some alert to ask confirmation if someone just touches it. Is there a way to do this ?

like image 517
Toseef Khilji Avatar asked Sep 28 '12 05:09

Toseef Khilji


2 Answers

Solved

I have used globalTintColor property of window,

like,

self.window.tintColor = [UIColor redColor];

Output:

enter image description here

like image 183
Toseef Khilji Avatar answered Nov 02 '22 05:11

Toseef Khilji


Use this:

self.textView.linkTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
like image 27
Ivan Vavilov Avatar answered Nov 02 '22 06:11

Ivan Vavilov