How To Set Link Color In Swift Programmatically

You can change the color of links in text views to anything you want in Swift.

The easiest way to do this is to set the tintColor of your UITextView:

textView.tintColor = UIColor.green

You can also do this by setting the link text attributes like so:

textView.linkTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red]
If you liked this post and want to learn more, check out The Complete iOS Developer Bootcamp. Speed up your learning curve - hundreds of students have already joined. Thanks for reading!
Profile Picture of Eddy Chung

Eddy Chung

I teach iOS development on ZeroToAppStore.com.

Similar Posts