swift - 无法在 iOS 15 中隐藏 ARSLineProgress

标签 swift uiactivityindicatorview

我是 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/

相关文章:

ios - 如何控制 UIActivityIndi​​catorView 的旋转?

objective-c - cocos2d 中的 UIActivityIndi​​catorView

ios - 未正确退出 App 时未关闭 OutputStream 文件

swift - CoreData 使用 iCloud,不使用同步通知

ios - 当我在 numberOfItemsInSection 中返回 1 时,cellForItemAt 未在 Swift 中调用

iphone - iPhone下载多个文件时添加activityIndi​​cator

swift - [UIActivityIndi​​catorView发布] : message sent to deallocated instance in swift-3

iphone - 全屏查看事件指示器

ios - 在 iOS 上用 swift 编写 XML

swift - 需要检查给定数组中的大括号是否平衡