Change attributed text color with link IOS

Viewed 2499

How I can change the attributed text color from blue to white?

When I click on the UITextView the app opens the url, I just need to change the color to white.

My code is in C# but I think it can be converted to swift or objective-c easily.

I have tried this way but it didn't work:

NSMutableAttributedString footerText = new NSMutableAttributedString(myFooterText, new UIStringAttributes
        {
            ForegroundColor = UIColor.White,

            Link = new NSUrl(myLinkString)
        });

        //Set footer text
        MyTextView.AttributedText = footerText;

enter image description here

5 Answers

The accepted answer is more of a workaround than a fix.

To change the link-color I used the code from Dhaval and changed it to Xamarin.iOS. Use the TintColor attribute like so:

var textColor = (Color)Element.GetValue(Label.TextColorProperty);
str.AddAttribute(UIStringAttributeKey.ForegroundColor, textColor.ToUIColor(Color.White), new NSRange(0, str.Length)); // Normal text color
str.AddAttribute(UIStringAttributeKey.Link, new NSUrl(item.Link), new NSRange(item.Start, item.Text.Length)); // Add a link.
            }
Control.TintColor = textColor.ToUIColor(Color.Wheat); // The LINK color
Control.AttributedText = str;
Related