// // Created by Tom Baranes on 23/08/16. // Copyright (c) 2016 IBAnimatable. All rights reserved. // import UIKit public class ActivityIndicatorAnimationSemiCircleSpin: ActivityIndicatorAnimating { // MARK: Properties fileprivate let duration: CFTimeInterval = 0.6 // MARK: ActivityIndicatorAnimating public func configureAnimation(in layer: CALayer, size: CGSize, color: UIColor) { let circle = ActivityIndicatorShape.circleSemi.makeLayer(size: size, color: color) let frame = CGRect( x: (layer.bounds.width - size.width) / 2, y: (layer.bounds.height - size.height) / 2, width: size.width, height: size.height ) circle.frame = frame circle.add(defaultAnimation, forKey: "animation") layer.addSublayer(circle) } } // MARK: - Setup private extension ActivityIndicatorAnimationSemiCircleSpin { var defaultAnimation: CAKeyframeAnimation { let animation = CAKeyframeAnimation(keyPath: .rotationZ) animation.keyTimes = [0, 0.5, 1] animation.values = [0, CGFloat.pi, 2 * CGFloat.pi] animation.duration = duration animation.repeatCount = .infinity animation.isRemovedOnCompletion = false return animation } }