Animation and other improvements

This commit is contained in:
Ali
2022-05-27 18:45:05 +04:00
parent 0d38a9bd08
commit bacd88a1ff
37 changed files with 498 additions and 426 deletions

View File

@@ -24,6 +24,7 @@ import UIKitRuntimeUtils
}
if let completion = self.completion {
completion(flag)
self.completion = nil
}
}
}
@@ -83,6 +84,9 @@ public extension CALayer {
animation.beginTime = self.convertTime(CACurrentMediaTime(), from: nil) + delay * UIView.animationDurationFactor()
animation.fillMode = .both
}
if #available(iOS 15.0, *) {
animation.preferredFrameRateRange = CAFrameRateRange(minimum: Float(UIScreen.main.maximumFramesPerSecond), maximum: Float(UIScreen.main.maximumFramesPerSecond), preferred: Float(UIScreen.main.maximumFramesPerSecond))
}
return animation
} else if timingFunction == kCAMediaTimingFunctionSpring {
let animation = makeSpringAnimation(keyPath)
@@ -108,6 +112,10 @@ public extension CALayer {
animation.fillMode = .both
}
if #available(iOS 15.0, *) {
animation.preferredFrameRateRange = CAFrameRateRange(minimum: Float(UIScreen.main.maximumFramesPerSecond), maximum: Float(UIScreen.main.maximumFramesPerSecond), preferred: Float(UIScreen.main.maximumFramesPerSecond))
}
return animation
} else {
let k = Float(UIView.animationDurationFactor())
@@ -138,6 +146,10 @@ public extension CALayer {
animation.fillMode = .both
}
if #available(iOS 15.0, *) {
animation.preferredFrameRateRange = CAFrameRateRange(minimum: Float(UIScreen.main.maximumFramesPerSecond), maximum: Float(UIScreen.main.maximumFramesPerSecond), preferred: Float(UIScreen.main.maximumFramesPerSecond))
}
return animation
}
}
@@ -196,6 +208,10 @@ public extension CALayer {
animation.delegate = CALayerAnimationDelegate(animation: animation, completion: completion)
}
if #available(iOS 15.0, *) {
animation.preferredFrameRateRange = CAFrameRateRange(minimum: Float(UIScreen.main.maximumFramesPerSecond), maximum: Float(UIScreen.main.maximumFramesPerSecond), preferred: Float(UIScreen.main.maximumFramesPerSecond))
}
self.add(animation, forKey: keyPath)
}
@@ -225,6 +241,10 @@ public extension CALayer {
animation.speed = speed * Float(animation.duration / duration)
animation.isAdditive = additive
if #available(iOS 15.0, *) {
animation.preferredFrameRateRange = CAFrameRateRange(minimum: Float(UIScreen.main.maximumFramesPerSecond), maximum: Float(UIScreen.main.maximumFramesPerSecond), preferred: Float(UIScreen.main.maximumFramesPerSecond))
}
return animation
}
@@ -257,6 +277,10 @@ public extension CALayer {
animation.speed = speed * Float(animation.duration / duration)
animation.isAdditive = additive
if #available(iOS 15.0, *) {
animation.preferredFrameRateRange = CAFrameRateRange(minimum: Float(UIScreen.main.maximumFramesPerSecond), maximum: Float(UIScreen.main.maximumFramesPerSecond), preferred: Float(UIScreen.main.maximumFramesPerSecond))
}
self.add(animation, forKey: keyPath)
}
@@ -284,6 +308,10 @@ public extension CALayer {
animation.delegate = CALayerAnimationDelegate(animation: animation, completion: completion)
}
if #available(iOS 15.0, *) {
animation.preferredFrameRateRange = CAFrameRateRange(minimum: Float(UIScreen.main.maximumFramesPerSecond), maximum: Float(UIScreen.main.maximumFramesPerSecond), preferred: Float(UIScreen.main.maximumFramesPerSecond))
}
self.add(animation, forKey: key)
}