diff --git a/SkeletonViewCore/Sources/API/AnimationBuilder/SkeletonAnimationBuilder.swift b/SkeletonViewCore/Sources/API/AnimationBuilder/SkeletonAnimationBuilder.swift index 321c9b13..c7a52bd2 100644 --- a/SkeletonViewCore/Sources/API/AnimationBuilder/SkeletonAnimationBuilder.swift +++ b/SkeletonViewCore/Sources/API/AnimationBuilder/SkeletonAnimationBuilder.swift @@ -27,10 +27,15 @@ public class SkeletonAnimationBuilder { let animGroup = CAAnimationGroup() animGroup.animations = [startPointAnim, endPointAnim] animGroup.duration = duration - animGroup.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn) animGroup.repeatCount = .infinity animGroup.autoreverses = autoreverses animGroup.isRemovedOnCompletion = false + + if #available(iOS 12.0, *) { + animGroup.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn) + } else { + animGroup.timingFunction = CAMediaTimingFunction(controlPoints: 0.42, 0.0, 1.0, 1.0) + } return animGroup } diff --git a/SkeletonViewCore/Sources/API/UIKitExtensions/CALayer+Animations.swift b/SkeletonViewCore/Sources/API/UIKitExtensions/CALayer+Animations.swift index 89d22194..87e518c3 100644 --- a/SkeletonViewCore/Sources/API/UIKitExtensions/CALayer+Animations.swift +++ b/SkeletonViewCore/Sources/API/UIKitExtensions/CALayer+Animations.swift @@ -22,10 +22,15 @@ public extension CALayer { // swiftlint:disable:next force_unwrapping pulseAnimation.toValue = UIColor(cgColor: backgroundColor!).complementaryColor.cgColor pulseAnimation.duration = 1 - pulseAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) pulseAnimation.autoreverses = true pulseAnimation.repeatCount = .infinity pulseAnimation.isRemovedOnCompletion = false + + if #available(iOS 12.0, *) { + pulseAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) + } else { + pulseAnimation.timingFunction = CAMediaTimingFunction(controlPoints: 0.42, 0.0, 0.58, 1.0) + } return pulseAnimation }