1

I am trying to set the text color of the Title and Message in a UIAlertController, but no matter which color I use, the text is always displayed with the same grey color. This affects both the foreground and background color of the text.

I am coding my app using Xamarin/C#, but I can translate Objective-C/Swift responses.

var alertController = new UIAlertController();

var alertTextAttributes = new UIStringAttributes
{
    ForegroundColor = UIColor.Red,
    BackgroundColor = UIColor.Yellow,
};


alertController.SetValueForKey(new NSAttributedString("Title", alertTextAttributes), new NSString("attributedTitle"));
alertController.SetValueForKey(new NSAttributedString("Message", alertTextAttributes), new NSString("attributedMessage"));


this.PresentViewController(alertController, true, null);

The alert renders like this for all colors.

enter image description here

I am able to change the font size and other attributes, just not colors.

Dave
  • 3,676
  • 4
  • 28
  • 39

0 Answers0