我是 swift 的新手,我无法在 iOS 15 中隐藏 ARSLineProgress。它在 iOS 15 以下运行良好。 我的代码是这样的
ARSLineProgress.hide()
hide()函数包含
public static func hide() {
ars_hideLoader(ars_currentLoader, withCompletionBlock: nil)
}
我已经从这个页面下载了 pod 文件
https://github.com/soberman/ARSLineProgress
有人遇到同样的问题吗
最佳答案
这已在以下 PR 中修复 https://github.com/soberman/ARSLineProgress/pull/36
修复方法是将 CATransaction.commit() 添加到隐藏函数中。这不是我的工作。
func ars_hideLoader(_ loader: ARSLoader?, withCompletionBlock block: (() -> Void)?) {
guard let loader = loader else { return }
ars_dispatchOnMainQueue {
let currentLayer = loader.emptyView.layer.presentation()
let alpha = Double(currentLayer?.opacity ?? 0)
let fixedTime = alpha * ars_config.backgroundViewDismissAnimationDuration
CATransaction.begin()
CATransaction.setCompletionBlock(block)
let alphaAnimation = CABasicAnimation(keyPath: "opacity")
alphaAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut)
alphaAnimation.fromValue = alpha
alphaAnimation.toValue = 0
alphaAnimation.duration = fixedTime
alphaAnimation.isRemovedOnCompletion = true
loader.emptyView.layer.removeAnimation(forKey: "alpha")
loader.emptyView.alpha = 0
loader.emptyView.layer.add(alphaAnimation, forKey: "alpha")
let scaleAnimation = CABasicAnimation(keyPath: "transform")
scaleAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut)
scaleAnimation.fromValue = CGAffineTransform(scaleX: 1, y: 1)
scaleAnimation.toValue = CGAffineTransform(scaleX: ars_config.backgroundViewDismissTransformScale,
y: ars_config.backgroundViewDismissTransformScale)
scaleAnimation.duration = fixedTime
scaleAnimation.isRemovedOnCompletion = true
loader.backgroundView.layer.removeAnimation(forKey: "transform")
loader.backgroundView.layer.add(scaleAnimation, forKey: "transform")
CATransaction.commit()
}
ars_dispatchAfter(ars_config.backgroundViewDismissAnimationDuration) {
ars_cleanupLoader(loader)
}
}
关于swift - 无法在 iOS 15 中隐藏 ARSLineProgress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69750222/