I am using UITextView
and i want to change the color of hyperlink which i use in this component. For example if UITextView
is showing www.gmail.com then it shows up in blue color. I want to change that color.
Asked
Active
Viewed 2.8k times
32

piotrpo
- 12,398
- 7
- 42
- 58

Muzamil Hassan
- 841
- 1
- 11
- 23
2 Answers
137
Huzzah! Apple have released a proper solution with iOS7! As explained in this answer you can use the linkTextAttributes
property of a UITextView
. A white, underlined link would look something like this:
yourTextView.linkTextAttributes = @{
NSForegroundColorAttributeName: [UIColor whiteColor],
NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle]
};
or alternatively you could change the tintColor
, since UITextView
inherits from UIView
and uses the tintColor
property to colour links - see:
yourTextView.tintColor = [UIColor whiteColor];
Now your links can look epic!

bompf
- 1,374
- 1
- 18
- 24

Tim Windsor Brown
- 4,069
- 5
- 25
- 33
-
Changing the link color by setting the yourTextView.linkTextAttributes makes the cursor look like its hovering over text and not over a link (hand cursor). Is there a way to fix that? – eli-bd Apr 22 '17 at 18:19
-
I found a way to fix the cursor issue: yourTextView.linkTextAttributes = [NSForegroundColorAttributeName : UIColor.redColor(), NSUnderlineStyleAttributeName : NSUnderlineStyle.StyleSingle.rawValue, NSCursorAttributeName: NSCursor.pointingHand()] – eli-bd Apr 22 '17 at 19:12
-
2nd one works for me – Abhishek Thapliyal Jan 17 '22 at 09:46
-8
The simple answer is you cannot do it.
Here's a workaround though:
Can I change the color of auto detected links on UITextView?

Community
- 1
- 1

HackyStack
- 4,887
- 3
- 22
- 28