gpt4 book ai didi

ios - 在 UIAlertController 中的 Action 下方显示一个空格

转载 作者:可可西里 更新时间:2023-11-01 03:37:46 27 4
gpt4 key购买 nike

iOS 8 之前的版本允许我创建一个 UIActionsheet,它会显示一组按钮、一些空格,然后是一个取消按钮。像这样:

Desired Behavior

但是在 iOS 8 中,当我尝试创建相同的外观时,我最终得到的结果如下所示:

iOS 8 Behavior

iOS 8 中的代码如下所示:

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

[alertVC.view setTintColor:[UIColor copperColor]];

UIAlertAction* notifyViaPush = [UIAlertAction
actionWithTitle:@"Send Alert to my phone"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alertVC dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* notifyViaEmail = [UIAlertAction
actionWithTitle:@"Notify me by email"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alertVC dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action)
{
[alertVC dismissViewControllerAnimated:YES completion:nil];
}];

[alertVC addAction:notifyViaPush];
[alertVC addAction:notifyViaEmail];
[alertVC addAction:cancel];

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

如何使用 UIAlertController 对按钮进行分组并在操作和取消按钮之间留出一些空间?

最佳答案

alertVC.view.tintColor = [UIColor copperColor]; 导致问题,它使警报 Controller 的整个 View 颜色相同,在您的第一张图片中,取消按钮具有白色背景。要解决此问题,请将此行移动到函数的末尾,即在您添加所有操作之后。

关于ios - 在 UIAlertController 中的 Action 下方显示一个空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28487743/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com