首页 > 解决方案 > 将加载动画放在 VNDocumentViewController Swift

问题描述

是否可以在 VNDocumentViewController 上放置加载动画?例如,当用户按下Save按钮时,有没有办法让我以某种方式表明Vision正在处理图像并且没有冻结?现在,在我的应用程序中,用户按下保存和正在处理的实际图像之间有很长的停顿。这是我正在尝试创建的另一篇文章的示例

标签: iosswiftanimationloadingvision

解决方案


这是一个使用 UIActivityIndi​​catorView() 添加加载指示器的示例。

startAnimating() 开始动画, stopAnimation() 停止动画。

iOS - 在屏幕中心而不是视图中显示进度指示器

guard let topWindow = UIApplication.shared.windows.last else {return}
let overlayView = UIView(frame: topWindow.bounds)
overlayView.backgroundColor = UIColor.clear
topWindow.addSubview(overlayView)
let hudView = UIActivityIndicatorView()
hudView.bounds = CGRect(x: 0, y: 0, width: 20, height: 20)
overlayView.addSubview(hudView)
hudView.center = overlayView.center
hudView.startAnimating()

或者,您可以考虑使用 Cocoapod MBProgressHud


推荐阅读