-1

I want to Change UIAlertController UIAlertAction TextColor and display Checkmark image when user Select an action.

i am able to show normal UIAlertController. but how can i achieve this?

Can any one please suggest me or help me to do that? Thanks

2 Answers2

0

It is not possible/advisable to override UIAlertAction textcolor. You will have to create your own view and present it as per your needs.There are some 3rd party libraries which can help you achieve what you want.

Maulik Bhuptani
  • 597
  • 3
  • 14
  • not getting your point. –  Sep 06 '17 at 12:52
  • 1
    It is not advisable to override private APIs/properties as your app may get rejected. Please refer Apple's documentation for it. So instead of modifying textcolor, create your own view which behaves like UIAlertController. You can use some 3rd party libraries to have look and feel of UIAlertController. I hope you agree. – Maulik Bhuptani Sep 06 '17 at 13:09
-1

Try this There's no need to use any 3rdParty Library

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel action") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){
        NSLog(@"Cancle Tapped");
        [alertController dismissViewControllerAnimated:YES completion:nil];
    }];

    [alertController addAction:cancelAction];

    UIAlertAction *yesAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"YES", @"YES action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
        NSLog(@"Yes Button Tapped");
    }];

    // Add CheckMark And Change CheckMark Color
    [yesAction setValue:YOUR_COLOUR forKey:@"titleTextColor"];
    [yesAction setValue:YOUR_COLOUR forKey:@"imageTintColor"];

    [alertController addAction:yesAction];

    UIAlertAction *noAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"NO", @"NO action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){

    }];

    // Add CheckMark And Change CheckMark Color
    [noAction setValue:YOUR_COLOUR forKey:@"titleTextColor"];
    [noAction setValue:YOUR_COLOUR forKey:@"imageTintColor"];
    [alertController addAction:noAction];

    [self presentViewController:alertController animated:YES completion:nil];

And If you want to set Any button with CheckMark by default than add this.

[yesAction setValue:@true forKey:@"checked"];
Kuldeep
  • 4,466
  • 8
  • 32
  • 59