我正在使用这个 swift 代码从 UIViewController
import UIKit
class TestViewController: UIViewController {
@IBAction func onTestClick(sender: UIButton) {
let alertController = UIAlertController(title: "title", message: "message", preferredStyle: .Alert)
alertController.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
}
}
当从具有深色(例如黑色)背景的 View 中显示警报时,它会短暂地“闪烁”(显示为白色,然后立即变为比白色稍暗的颜色)。
这似乎不会发生在其他应用程序和系统操作系统上。
这里有什么问题?
最佳答案
我能够重现您所说的内容,而且我认为您实际上并没有做错什么。如果您在模拟器 (cmd + t) 上打开慢速动画,您将看到警报 Controller 以渐变动画的形式位于屏幕中央。当动画进行时,警报 Controller 有一个白色背景(这是 Apple 的代码,很好),当动画结束时,警报 Controller 有一个透明背景,它会根据它后面的 View 的颜色而改变。当 View 是白色时你不会注意到任何东西,因为白色 + 白色 = 白色! :)
希望对您有所帮助。
关于ios - UIAlertViewController 短暂闪烁/闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34915166/