使用UIAlertController时更改警报操作背景突出显示

时间:2017-09-27 10:36:54

标签: ios objective-c uialertcontroller xcode9 uialertaction

我试图更改alertcontroller的背景突出显示颜色。例如,在下图中,现在单元格的默认背景高光为浅灰色,我需要将其更改为其他颜色。我看到了关于改变色调颜色的各种帖子,但我不需要仅改变背景高光的标题颜色。这可能吗?

enter image description here

//这是我当前的代码

- (IBAction)showAlert:(UIButton *)sender {

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


    UIAlertAction* save = [UIAlertAction
                                actionWithTitle:@"Save"
                                style:UIAlertActionStyleDefault
                                handler:^(UIAlertAction * action)
                                {
                                    //Perform some action


                                }];

    UIAlertAction* saveas = [UIAlertAction
                                actionWithTitle:@"Save As"
                                style:UIAlertActionStyleDefault
                                handler:^(UIAlertAction * action)
                                {
                                    //Perform some action


                                }];

    UIAlertAction* discard = [UIAlertAction
                                actionWithTitle:@"Discard"
                                style:UIAlertActionStyleDestructive
                                handler:^(UIAlertAction * action)
                                {
                                    //Perform some action


                                }];

    [alert addAction:save];
    [alert addAction:saveas];
    [alert addAction:discard];


    [alert setModalPresentationStyle:UIModalPresentationPopover];
    UIPopoverPresentationController *popPresenter = [alert popoverPresentationController];

    popPresenter.sourceView = sender;
    popPresenter.sourceRect = sender.bounds;
    [self presentViewController:alert animated:YES completion:nil];


}

0 个答案:

没有答案