在 UIAlertView 叠加层上方添加按钮

Add button above UIAlertView overlay

我想在警报覆盖层上方而不是在其内容中添加按钮。

我尝试在 window 中添加按钮,并将其置于最前面。但是,按钮仍然在叠加层下方。

let button = UIButton(type: .Custom)
window.addSubview(button)
window.bringSubviewToFront(button)

有没有办法不使用自定义警报视图?谢谢!

不,没有,因为这是 Apple 私有的一部分 API(UIAlertView 中的视图)

您需要 UIAlertView 的自定义实现才能执行此操作。