Change Color of a UIAlertAction

Hello,

I want to change the color of ONE of those button in my UIAlertController :
image

I know if I do that :

var actionSheetAlert = UIAlertController.Create("Modes", "", UIAlertControllerStyle.Alert);
actionSheetAlert.View.TintColor = UIColor.Gray;

It will change the color of the of all the buttons. But I want to change the color of the first button.
How can I do it ?

My code :

var actionSheetAlert = UIAlertController.Create("Modes", "", UIAlertControllerStyle.Alert);
UIAlertAction buttonModeZone = UIAlertAction.Create("Mode Zone"
, UIAlertActionStyle.Default
, (action) => callback1.Invoke());
var imageModeZone => UIImage.FromBundle("ModeZone.png").ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
var resizeImageModeZone = ImageHelper.ResizeImage(imageModeZone, 50, 50).ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
buttonModeZone.SetValueForKey(resizeImageModeZone, new NSString("image"));
actionSheetAlert.AddAction(buttonModeZone);
actionSheetAlert.AddAction(UIAlertAction.Create("Fermer", UIAlertActionStyle.Cancel, null));

I was searching with that but nothing work :

var myText = new NSAttributedString("Title",
new UIStringAttributes()
{
ForegroundColor = UIColor.Red,
KerningAdjustment = 3
});
buttonModeZone.SetValueForKey(myText, new NSString("attributedTitle"));

Posts

  • LucCadoretLucCadoret FRMember

    C'est bon j'ai trouvé.
    Si ça peut aider des gens :)

    buttonModeZone.SetValueForKey(UIColor.FromRGB(98,218,115), new NSString("titleTextColor"));

  • christopherpolskachristopherpolska PLUniversity ✭✭✭

    @LucCadoret said:
    C'est bon j'ai trouvé.
    Si ça peut aider des gens :)

    buttonModeZone.SetValueForKey(UIColor.FromRGB(98,218,115), new NSString("titleTextColor"));

    Learn some English.

Sign In or Register to comment.