【发布时间】:2020-04-28 13:53:36
【问题描述】:
就我而言,我需要将 UIAlertController 倒置显示给用户。
目前,我可以通过以下方式避免开场动画:
present(alert, animated: false, completion: {
alert.view.transform = CGAffineTransform(rotationAngle: .pi)
})
此时,用户看到的是倒置的 UIAlertController。
而且在关闭的时候,点击取消后,UIAlertController 会在正常位置闪烁百分之一秒,稍微破坏了用户体验。
通过这个简单的例子,你可以捕捉到这种轻微的眨眼:
let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert)
let action = UIAlertAction(title: "Action", style: .default, handler: { action in })
let cancel = UIAlertAction(title: "Cancel", style: .destructive, handler: { action in })
alert.addAction(action)
alert.addAction(cancel)
present(alert, animated: false, completion: {
alert.view.transform = CGAffineTransform(rotationAngle: .pi)
})
我试着打电话
alert.dismiss(animated: false, completion: nil)
或
alert.view.isHidden = true
在取消操作中,但它不起作用。
帮我想办法避免这个烦人的结束动画。
【问题讨论】:
-
问题是你不负责警报的解除;当用户点击按钮时它是自动的。使用自定义呈现的视图控制器(看起来和行为都像警报)会更好。
-
糟糕,看来这是唯一正确的解决方案。
-
我不知道这个想法有什么问题。 UIAlertController 是呈现的视图控制器,因此没有区别。您是试图滥用警报的人。
标签: swift animation uialertcontroller dismiss