Not able to hide ARSLineProgress in iOS 15

138 Views Asked by At

I am new in swift and I am not able to hide ARSLineProgress in iOS 15. Its was working fine below iOS 15. My code is like this

ARSLineProgress.hide()

The hide() function contain

public static func hide() {
ars_hideLoader(ars_currentLoader, withCompletionBlock: nil)
}

I have download pod file from this page

https://github.com/soberman/ARSLineProgress

Did someone face the same issue

1

There are 1 best solutions below

1
Burf2000 On

This has been fixed on the following PR https://github.com/soberman/ARSLineProgress/pull/36

The fix is to add CATransaction.commit() to the hide function. This was not my work.

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)
    }
}