diff --git a/EasyAnimation.xcodeproj/project.pbxproj b/EasyAnimation.xcodeproj/project.pbxproj index 6ac3938..43ca1e5 100644 --- a/EasyAnimation.xcodeproj/project.pbxproj +++ b/EasyAnimation.xcodeproj/project.pbxproj @@ -178,7 +178,6 @@ LastSwiftMigration = 0800; }; 72A03EEA1C29784A002DA467 = { - DevelopmentTeam = 29X3GG489T; DevelopmentTeamName = "Bakken & Bæck AS"; }; }; @@ -343,6 +342,7 @@ 4034826B1B8E01ED006C3C7C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -355,7 +355,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.easyanimation.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -375,7 +375,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -383,6 +383,7 @@ isa = XCBuildConfiguration; buildSettings = { DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -394,7 +395,7 @@ PRODUCT_NAME = EasyAnimation; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -404,6 +405,7 @@ isa = XCBuildConfiguration; buildSettings = { DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -416,7 +418,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; diff --git a/EasyAnimation/EAAnimationFuture.swift b/EasyAnimation/EAAnimationFuture.swift index dabf98a..356aedb 100644 --- a/EasyAnimation/EAAnimationFuture.swift +++ b/EasyAnimation/EAAnimationFuture.swift @@ -41,7 +41,7 @@ public class EAAnimationFuture: Equatable, CustomStringConvertible { /* animation properties */ var duration: CFTimeInterval = 0.0 var delay: CFTimeInterval = 0.0 - var options: UIViewAnimationOptions = [] + var options: UIView.AnimationOptions = [] var animations: (() -> Void)? var completion: ((Bool) -> Void)? @@ -101,12 +101,12 @@ public class EAAnimationFuture: Equatable, CustomStringConvertible { } @discardableResult - public func animate(withDuration duration: TimeInterval, delay: TimeInterval, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { + public func animate(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { return animateAndChain(withDuration: duration, delay: delay, options: options, animations: animations, completion: completion) } @discardableResult - public func animate(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { + public func animate(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { let anim = animateAndChain(withDuration: duration, delay: delay, options: options, animations: animations, completion: completion) self.springDamping = dampingRatio self.springVelocity = velocity @@ -114,7 +114,7 @@ public class EAAnimationFuture: Equatable, CustomStringConvertible { } @discardableResult - public func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { + public func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { var options = options if options.contains(.repeat) { diff --git a/EasyAnimation/EasyAnimation.swift b/EasyAnimation/EasyAnimation.swift index a66a8a5..9622f52 100644 --- a/EasyAnimation/EasyAnimation.swift +++ b/EasyAnimation/EasyAnimation.swift @@ -38,7 +38,7 @@ private class AnimationContext { var duration: TimeInterval = 1.0 var currentTime: TimeInterval = {CACurrentMediaTime()}() var delay: TimeInterval = 0.0 - var options: UIViewAnimationOptions? = nil + var options: UIView.AnimationOptions? = nil var pendingAnimations = [PendingAnimation]() //spring additions @@ -110,16 +110,16 @@ private let specializedLayerKeys: [String: [String]] = [ CATextLayer.self.description(): ["fontSize", "foregroundColor"] ] -public extension UIViewAnimationOptions { +public extension UIView.AnimationOptions { //CA Fill modes - static let fillModeNone = UIViewAnimationOptions(rawValue: 0) - static let fillModeForwards = UIViewAnimationOptions(rawValue: 1024) - static let fillModeBackwards = UIViewAnimationOptions(rawValue: 2048) - static let fillModeBoth = UIViewAnimationOptions(rawValue: 1024 + 2048) + static let fillModeNone = UIView.AnimationOptions(rawValue: 0) + static let fillModeForwards = UIView.AnimationOptions(rawValue: 1024) + static let fillModeBackwards = UIView.AnimationOptions(rawValue: 2048) + static let fillModeBoth = UIView.AnimationOptions(rawValue: 1024 + 2048) //CA Remove on completion - static let isRemovedOnCompletion = UIViewAnimationOptions(rawValue: 0) - static let isNotRemovedOnCompletion = UIViewAnimationOptions(rawValue: 16384) + static let isRemovedOnCompletion = UIView.AnimationOptions(rawValue: 0) + static let isNotRemovedOnCompletion = UIView.AnimationOptions(rawValue: 16384) } /** @@ -200,7 +200,7 @@ extension UIView { } @objc - class func EA_animate(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIViewAnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?) { + class func EA_animate(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIView.AnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?) { //create context let context = AnimationContext() context.duration = duration @@ -240,7 +240,7 @@ extension UIView { } @objc - class func EA_animate(withDuration duration: TimeInterval, delay: TimeInterval, options: UIViewAnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?) { + class func EA_animate(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.AnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?) { //create context let context = AnimationContext() @@ -348,45 +348,45 @@ extension UIView { if context.delay > 0.0 { anim.beginTime = context.currentTime + context.delay - anim.fillMode = kCAFillModeBackwards + anim.fillMode = CAMediaTimingFillMode.backwards } //options if let options = context.options?.rawValue { - if options & UIViewAnimationOptions.beginFromCurrentState.rawValue == 0 { //only repeat if not in a chain - anim.autoreverses = (options & UIViewAnimationOptions.autoreverse.rawValue == UIViewAnimationOptions.autoreverse.rawValue) - anim.repeatCount = (options & UIViewAnimationOptions.repeat.rawValue == UIViewAnimationOptions.repeat.rawValue) ? Float.infinity : 0 + if options & UIView.AnimationOptions.beginFromCurrentState.rawValue == 0 { //only repeat if not in a chain + anim.autoreverses = (options & UIView.AnimationOptions.autoreverse.rawValue == UIView.AnimationOptions.autoreverse.rawValue) + anim.repeatCount = (options & UIView.AnimationOptions.repeat.rawValue == UIView.AnimationOptions.repeat.rawValue) ? Float.infinity : 0 } //easing - var timingFunctionName = kCAMediaTimingFunctionEaseInEaseOut + var timingFunctionName = CAMediaTimingFunctionName.easeInEaseOut - if options & UIViewAnimationOptions.curveLinear.rawValue == UIViewAnimationOptions.curveLinear.rawValue { + if options & UIView.AnimationOptions.curveLinear.rawValue == UIView.AnimationOptions.curveLinear.rawValue { //first check for linear (it's this way to take up only 2 bits) - timingFunctionName = kCAMediaTimingFunctionLinear - } else if options & UIViewAnimationOptions.curveEaseIn.rawValue == UIViewAnimationOptions.curveEaseIn.rawValue { - timingFunctionName = kCAMediaTimingFunctionEaseIn - } else if options & UIViewAnimationOptions.curveEaseOut.rawValue == UIViewAnimationOptions.curveEaseOut.rawValue { - timingFunctionName = kCAMediaTimingFunctionEaseOut + timingFunctionName = CAMediaTimingFunctionName.linear + } else if options & UIView.AnimationOptions.curveEaseIn.rawValue == UIView.AnimationOptions.curveEaseIn.rawValue { + timingFunctionName = CAMediaTimingFunctionName.easeIn + } else if options & UIView.AnimationOptions.curveEaseOut.rawValue == UIView.AnimationOptions.curveEaseOut.rawValue { + timingFunctionName = CAMediaTimingFunctionName.easeOut } anim.timingFunction = CAMediaTimingFunction(name: timingFunctionName) //fill mode - if options & UIViewAnimationOptions.fillModeBoth.rawValue == UIViewAnimationOptions.fillModeBoth.rawValue { + if options & UIView.AnimationOptions.fillModeBoth.rawValue == UIView.AnimationOptions.fillModeBoth.rawValue { //both - anim.fillMode = kCAFillModeBoth - } else if options & UIViewAnimationOptions.fillModeForwards.rawValue == UIViewAnimationOptions.fillModeForwards.rawValue { + anim.fillMode = CAMediaTimingFillMode.both + } else if options & UIView.AnimationOptions.fillModeForwards.rawValue == UIView.AnimationOptions.fillModeForwards.rawValue { //forward - anim.fillMode = (anim.fillMode == kCAFillModeBackwards) ? kCAFillModeBoth : kCAFillModeForwards - } else if options & UIViewAnimationOptions.fillModeBackwards.rawValue == UIViewAnimationOptions.fillModeBackwards.rawValue { + anim.fillMode = (anim.fillMode == CAMediaTimingFillMode.backwards) ? CAMediaTimingFillMode.both : CAMediaTimingFillMode.forwards + } else if options & UIView.AnimationOptions.fillModeBackwards.rawValue == UIView.AnimationOptions.fillModeBackwards.rawValue { //backwards - anim.fillMode = kCAFillModeBackwards + anim.fillMode = CAMediaTimingFillMode.backwards } //is removed on completion - if options & UIViewAnimationOptions.isNotRemovedOnCompletion.rawValue == UIViewAnimationOptions.isNotRemovedOnCompletion.rawValue { + if options & UIView.AnimationOptions.isNotRemovedOnCompletion.rawValue == UIView.AnimationOptions.isNotRemovedOnCompletion.rawValue { anim.isRemovedOnCompletion = false } else { anim.isRemovedOnCompletion = true @@ -409,7 +409,7 @@ extension UIView { :returns: The created request. */ - public class func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { + public class func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { let currentAnimation = EAAnimationFuture() currentAnimation.duration = duration @@ -440,7 +440,7 @@ extension UIView { :returns: The created request. */ - public class func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIViewAnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { + public class func animateAndChain(withDuration duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIView.AnimationOptions, animations: @escaping () -> Void, completion: ((Bool) -> Void)?) -> EAAnimationFuture { let currentAnimation = EAAnimationFuture() currentAnimation.duration = duration diff --git a/EasyAnimation/RBBSpringAnimation/RBBSpringAnimation.swift b/EasyAnimation/RBBSpringAnimation/RBBSpringAnimation.swift index 74c5d69..9ff5dcb 100644 --- a/EasyAnimation/RBBSpringAnimation/RBBSpringAnimation.swift +++ b/EasyAnimation/RBBSpringAnimation/RBBSpringAnimation.swift @@ -66,7 +66,7 @@ class RBBSpringAnimation: CAKeyframeAnimation { mass = 1 stiffness = 100 - calculationMode = kCAAnimationDiscrete + calculationMode = CAAnimationCalculationMode.discrete } required init(coder aDecoder: NSCoder) {