From 210fd1b1235f68214f8ac8b9ccfd64d06b95793e Mon Sep 17 00:00:00 2001 From: Draveness Date: Thu, 25 Jun 2015 19:31:14 +0800 Subject: [PATCH 01/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac57100..dcfaf69 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a swift port for JHChainableAnimations by [jhurray](https://github.com/j # Demo ![language](https://img.shields.io/badge/Language-%20Swift%20-orange.svg) -![Version](https://img.shields.io/badge/Pod-%20v1.3.0%20-or.svg) +[![Version](http://img.shields.io/cocoapods/v/DKChainableAnimationKit.svg?style=flat)](http://cocoadocs.org/docsets/DKChainableAnimationKit) ![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg) ![MIT License](https://img.shields.io/github/license/mashape/apistatus.svg) ![Platform](https://img.shields.io/badge/platform-%20iOS%20-lightgrey.svg) From e458c631fede04849ad9bc69f1ac1a018a18ef84 Mon Sep 17 00:00:00 2001 From: Daniel Asher Date: Sat, 1 Aug 2015 04:26:22 +0100 Subject: [PATCH 02/12] fixed transformScale bug by replacing CATransform3DTranslate with CATransform3DScale --- .../Classes/DKChainableAnimationKit+Transform.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Transform.swift b/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Transform.swift index 1056062..9619043 100644 --- a/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Transform.swift +++ b/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Transform.swift @@ -99,14 +99,14 @@ extension DKChainableAnimationKit { self.addAnimationCalculationAction { (view: UIView) -> Void in let transformAnimation = self.basicAnimationForKeyPath("transform") var transform = view.layer.transform - transform = CATransform3DTranslate(transform, scale, scale, 1) + transform = CATransform3DScale(transform, scale, scale, 1) transformAnimation.fromValue = NSValue(CATransform3D: view.layer.transform) transformAnimation.toValue = NSValue(CATransform3D: transform) self.addAnimationFromCalculationBlock(transformAnimation) } self.addAnimationCompletionAction { (view: UIView) -> Void in var transform = view.layer.transform - transform = CATransform3DTranslate(transform, scale, scale, 1) + transform = CATransform3DScale(transform, scale, scale, 1) view.layer.transform = transform } return self @@ -116,14 +116,14 @@ extension DKChainableAnimationKit { self.addAnimationCalculationAction { (view: UIView) -> Void in let transformAnimation = self.basicAnimationForKeyPath("transform") var transform = view.layer.transform - transform = CATransform3DTranslate(transform, scaleX, 1, 1) + transform = CATransform3DScale(transform, scaleX, 1, 1) transformAnimation.fromValue = NSValue(CATransform3D: view.layer.transform) transformAnimation.toValue = NSValue(CATransform3D: transform) self.addAnimationFromCalculationBlock(transformAnimation) } self.addAnimationCompletionAction { (view: UIView) -> Void in var transform = view.layer.transform - transform = CATransform3DTranslate(transform, scaleX, 1, 1) + transform = CATransform3DScale(transform, scaleX, 1, 1) view.layer.transform = transform } return self @@ -133,14 +133,14 @@ extension DKChainableAnimationKit { self.addAnimationCalculationAction { (view: UIView) -> Void in let transformAnimation = self.basicAnimationForKeyPath("transform") var transform = view.layer.transform - transform = CATransform3DTranslate(transform, 1, scaleY, 1) + transform = CATransform3DScale(transform, 1, scaleY, 1) transformAnimation.fromValue = NSValue(CATransform3D: view.layer.transform) transformAnimation.toValue = NSValue(CATransform3D: transform) self.addAnimationFromCalculationBlock(transformAnimation) } self.addAnimationCompletionAction { (view: UIView) -> Void in var transform = view.layer.transform - transform = CATransform3DTranslate(transform, 1, scaleY, 1) + transform = CATransform3DScale(transform, 1, scaleY, 1) view.layer.transform = transform } return self From 5a3c47d27d9b9f7169ca36a79892d1b5365e3ccc Mon Sep 17 00:00:00 2001 From: Draveness Date: Mon, 24 Aug 2015 11:49:26 +0800 Subject: [PATCH 03/12] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dcfaf69..93826d6 100644 --- a/README.md +++ b/README.md @@ -385,10 +385,13 @@ Animation effects does not work on path movement. +# Swift 2.0 + +If you would like to use this repo with Swift 2.0, checkout `swift-2.0` branch. + # To Do * Support OS X -* Support Swift 2.0 ---- From 314da7bfde1ec32baddc44ae927465d018da0162 Mon Sep 17 00:00:00 2001 From: Draveness Date: Fri, 18 Sep 2015 11:25:20 +0800 Subject: [PATCH 04/12] Updated to swift 2.0 --- .../project.pbxproj | 9 +++++++- .../DKChainableAnimationKit.xcscheme | 13 ++++++----- .../DKChainableAnimationKit+Anchor.swift | 2 +- .../DKChainableAnimationKit+Extra.swift | 2 +- .../DKChainableAnimationKit+Frame.swift | 2 +- .../Classes/DKChainableAnimationKit.swift | 4 ++-- .../Classes/DKKeyFrameAnimation.swift | 22 +++++++++---------- .../Classes/DKKeyframeAnimationFunction.swift | 20 ++++++++--------- .../Classes/UIView+AnimationKit.swift | 2 +- DKChainableAnimationKit/Info.plist | 2 +- DKChainableAnimationKitTests/Info.plist | 2 +- .../xcschemes/iOS Example.xcscheme | 13 ++++++----- iOS Example/ViewController.swift | 2 +- 13 files changed, 54 insertions(+), 41 deletions(-) diff --git a/DKChainableAnimationKit.xcodeproj/project.pbxproj b/DKChainableAnimationKit.xcodeproj/project.pbxproj index a3c2ce5..32f6c3c 100644 --- a/DKChainableAnimationKit.xcodeproj/project.pbxproj +++ b/DKChainableAnimationKit.xcodeproj/project.pbxproj @@ -196,7 +196,9 @@ 5287D66B1B1120E6006A9A84 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastSwiftMigration = 0700; + LastSwiftUpdateCheck = 0700; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = DeltaX; TargetAttributes = { 5287D6731B1120E6006A9A84 = { @@ -301,6 +303,7 @@ CURRENT_PROJECT_VERSION = 1.3; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -378,6 +381,7 @@ INFOPLIST_FILE = DKChainableAnimationKit/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.draveness.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; @@ -393,6 +397,7 @@ INFOPLIST_FILE = DKChainableAnimationKit/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.draveness.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; @@ -411,6 +416,7 @@ ); INFOPLIST_FILE = DKChainableAnimationKitTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.draveness.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -424,6 +430,7 @@ ); INFOPLIST_FILE = DKChainableAnimationKitTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.draveness.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/DKChainableAnimationKit.xcodeproj/xcshareddata/xcschemes/DKChainableAnimationKit.xcscheme b/DKChainableAnimationKit.xcodeproj/xcshareddata/xcschemes/DKChainableAnimationKit.xcscheme index 457dc10..218c4d6 100644 --- a/DKChainableAnimationKit.xcodeproj/xcshareddata/xcschemes/DKChainableAnimationKit.xcscheme +++ b/DKChainableAnimationKit.xcodeproj/xcshareddata/xcschemes/DKChainableAnimationKit.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -62,15 +62,18 @@ ReferencedContainer = "container:DKChainableAnimationKit.xcodeproj"> + + DKChainableAnimationKit { self.addAnimationCalculationAction { (view: UIView) -> Void in let borderColorAnimation = self.basicAnimationForKeyPath("borderColor") - borderColorAnimation.fromValue = UIColor(CGColor: view.layer.borderColor) + borderColorAnimation.fromValue = UIColor(CGColor: view.layer.borderColor!) borderColorAnimation.toValue = color self.addAnimationFromCalculationBlock(borderColorAnimation) } diff --git a/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift b/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift index 2c192fd..c44fcea 100644 --- a/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift +++ b/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift @@ -38,7 +38,7 @@ public extension DKChainableAnimationKit { } self.addAnimationCompletionAction { (view: UIView) -> Void in - var bounds = CGRect(x: 0, y: 0, width: width, height: height) + let bounds = CGRect(x: 0, y: 0, width: width, height: height) view.layer.bounds = bounds view.bounds = bounds } diff --git a/DKChainableAnimationKit/Classes/DKChainableAnimationKit.swift b/DKChainableAnimationKit/Classes/DKChainableAnimationKit.swift index ee4376c..4550b03 100644 --- a/DKChainableAnimationKit/Classes/DKChainableAnimationKit.swift +++ b/DKChainableAnimationKit/Classes/DKChainableAnimationKit.swift @@ -267,14 +267,14 @@ public class DKChainableAnimationKit { return animation } - internal func newPositionFrom(#newOrigin: CGPoint) -> CGPoint { + internal func newPositionFrom(newOrigin newOrigin: CGPoint) -> CGPoint { let anchor = self.view.layer.anchorPoint let size = self.view.bounds.size let newPosition = CGPoint(x: newOrigin.x + anchor.x * size.width, y: newOrigin.y + anchor.y * size.height) return newPosition } - internal func newPositionFrom(#newCenter: CGPoint) -> CGPoint { + internal func newPositionFrom(newCenter newCenter: CGPoint) -> CGPoint { let anchor = self.view.layer.anchorPoint let size = self.view.bounds.size let newPosition = CGPoint(x: newCenter.x + (anchor.x - 0.5) * size.width, y: newCenter.y + (anchor.y - 0.5) * size.height) diff --git a/DKChainableAnimationKit/Classes/DKKeyFrameAnimation.swift b/DKChainableAnimationKit/Classes/DKKeyFrameAnimation.swift index 52469a0..4af2751 100644 --- a/DKChainableAnimationKit/Classes/DKKeyFrameAnimation.swift +++ b/DKChainableAnimationKit/Classes/DKKeyFrameAnimation.swift @@ -48,8 +48,8 @@ public class DKKeyFrameAnimation: CAKeyframeAnimation { self.fromValue.objCType let valueType: NSString! = NSString(CString: self.fromValue.objCType, encoding: 1) if valueType.containsString("CGRect") { - let fromRect = self.fromValue.CGRectValue() - let toRect = self.toValue.CGRectValue() + let fromRect = self.fromValue.CGRectValue + let toRect = self.toValue.CGRectValue let xValues = self.valueArrayFor(startValue: fromRect.origin.x, endValue: toRect.origin.x) as! [CGFloat] let yValues = self.valueArrayFor(startValue: fromRect.origin.y, endValue: toRect.origin.x) as! [CGFloat] @@ -59,8 +59,8 @@ public class DKKeyFrameAnimation: CAKeyframeAnimation { self.values = self.rectArrayFrom(xValues: xValues, yValues: yValues, widthValues: widthValues, heightValues: heightValues) as [AnyObject] } else if valueType.containsString("CGPoint") { - let fromPoint = self.fromValue.CGPointValue() - let toPoint = self.toValue.CGPointValue() + let fromPoint = self.fromValue.CGPointValue + let toPoint = self.toValue.CGPointValue let path = self.createPathFromXYValues(self.valueArrayFor(startValue: fromPoint.x, endValue: toPoint.x), yValues: self.valueArrayFor(startValue: fromPoint.y, endValue: toPoint.y)) self.path = path } else if valueType.containsString("CGSize") { @@ -101,12 +101,12 @@ public class DKKeyFrameAnimation: CAKeyframeAnimation { } private func createTransformArrayFrom( - #m11: NSArray, m12: NSArray, m13: NSArray, m14: NSArray, + m11 m11: NSArray, m12: NSArray, m13: NSArray, m14: NSArray, m21: NSArray, m22: NSArray, m23: NSArray, m24: NSArray, m31: NSArray, m32: NSArray, m33: NSArray, m34: NSArray, m41: NSArray, m42: NSArray, m43: NSArray, m44: NSArray) -> NSArray { let numberOfTransforms = m11.count; - var values = NSMutableArray(capacity: numberOfTransforms) + let values = NSMutableArray(capacity: numberOfTransforms) var value: CATransform3D! for (var i = 1; i < numberOfTransforms; i++) { value = CATransform3DIdentity; @@ -155,9 +155,9 @@ public class DKKeyFrameAnimation: CAKeyframeAnimation { return self.fromValue.isKindOfClass(klass) && self.toValue.isKindOfClass(klass) } - private func rectArrayFrom(#xValues: [CGFloat], yValues: [CGFloat], widthValues: [CGFloat], heightValues: [CGFloat]) -> NSArray { + private func rectArrayFrom(xValues xValues: [CGFloat], yValues: [CGFloat], widthValues: [CGFloat], heightValues: [CGFloat]) -> NSArray { let numberOfRects = xValues.count - var values: NSMutableArray = [] + let values: NSMutableArray = [] var value: NSValue for i in 1.. [CGColor] { + private func colorArrayFrom(redValues redValues: [CGFloat], greenValues: [CGFloat], blueValues: [CGFloat], alphaValues: [CGFloat]) -> [CGColor] { let numberOfColors = redValues.count var values: [CGColor] = [] var value: CGColor! @@ -180,7 +180,7 @@ public class DKKeyFrameAnimation: CAKeyframeAnimation { return values } - private func valueArrayFor(#startValue: CGFloat, endValue: CGFloat) -> NSArray { + private func valueArrayFor(startValue startValue: CGFloat, endValue: CGFloat) -> NSArray { let startValue = Double(startValue) let endValue = Double(endValue) @@ -192,7 +192,7 @@ public class DKKeyFrameAnimation: CAKeyframeAnimation { var valueArray: [Double] = [] - for i in 0.. Double { +func DKKeyframeAnimationFunctionEaseInSine(t: Double, b: Double, c: Double, d: Double) -> Double { return -c * cos(t / d * (M_PI_2)) + c + b; } -func DKKeyframeAnimationFunctionEaseOutSine(var t: Double, b: Double, c: Double, d: Double) -> Double { +func DKKeyframeAnimationFunctionEaseOutSine(t: Double, b: Double, c: Double, d: Double) -> Double { return c * sin(t / d * (M_PI_2)) + b; } -func DKKeyframeAnimationFunctionEaseInOutSine(var t: Double, b: Double, c: Double, d: Double) -> Double { +func DKKeyframeAnimationFunctionEaseInOutSine(t: Double, b: Double, c: Double, d: Double) -> Double { return -c / 2 * (cos(M_PI * t / d) - 1) + b; } -func DKKeyframeAnimationFunctionEaseInExpo(var t: Double, b: Double, c: Double, d: Double) -> Double { +func DKKeyframeAnimationFunctionEaseInExpo(t: Double, b: Double, c: Double, d: Double) -> Double { return (t==0) ? b : c * pow(2, 10 * (t / d - 1)) + b; } -func DKKeyframeAnimationFunctionEaseOutExpo(var t: Double, b: Double, c: Double, d: Double) -> Double { +func DKKeyframeAnimationFunctionEaseOutExpo(t: Double, b: Double, c: Double, d: Double) -> Double { return (t == d) ? b+c : c * (-pow(2, -10 * t / d) + 1) + b; } @@ -252,8 +252,8 @@ func DKKeyframeAnimationFunctionEaseInOutBack(var t: Double, b: Double, c: Doubl } } -func DKKeyframeAnimationFunctionEaseInBounce(var t: Double, b: Double, c: Double, d: Double) -> Double { - return c - DKKeyframeAnimationFunctionEaseOutBounce(d - t, 0, c, d) + b; +func DKKeyframeAnimationFunctionEaseInBounce(t: Double, b: Double, c: Double, d: Double) -> Double { + return c - DKKeyframeAnimationFunctionEaseOutBounce(d - t, b: 0, c: c, d: d) + b; } func DKKeyframeAnimationFunctionEaseOutBounce(var t: Double, b: Double, c: Double, d: Double) -> Double { @@ -272,10 +272,10 @@ func DKKeyframeAnimationFunctionEaseOutBounce(var t: Double, b: Double, c: Doubl } } -func DKKeyframeAnimationFunctionEaseInOutBounce(var t: Double, b: Double, c: Double, d: Double) -> Double { +func DKKeyframeAnimationFunctionEaseInOutBounce(t: Double, b: Double, c: Double, d: Double) -> Double { if t < d / 2 { - return DKKeyframeAnimationFunctionEaseInBounce (t * 2, 0, c, d) * 0.5 + b; + return DKKeyframeAnimationFunctionEaseInBounce (t * 2, b: 0, c: c, d: d) * 0.5 + b; } else { - return DKKeyframeAnimationFunctionEaseOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b; + return DKKeyframeAnimationFunctionEaseOutBounce(t * 2 - d, b: 0, c: c, d: d) * 0.5 + c * 0.5 + b; } } \ No newline at end of file diff --git a/DKChainableAnimationKit/Classes/UIView+AnimationKit.swift b/DKChainableAnimationKit/Classes/UIView+AnimationKit.swift index 760f2d2..97a9ee1 100644 --- a/DKChainableAnimationKit/Classes/UIView+AnimationKit.swift +++ b/DKChainableAnimationKit/Classes/UIView+AnimationKit.swift @@ -20,7 +20,7 @@ public extension UIView { } else { animation = DKChainableAnimationKit() animation.view = self - objc_setAssociatedObject(self, &animationKitAssociationKey, animation, objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN)) + objc_setAssociatedObject(self, &animationKitAssociationKey, animation, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN) return animation } } diff --git a/DKChainableAnimationKit/Info.plist b/DKChainableAnimationKit/Info.plist index 567726f..0e600e6 100644 --- a/DKChainableAnimationKit/Info.plist +++ b/DKChainableAnimationKit/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.draveness.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/DKChainableAnimationKitTests/Info.plist b/DKChainableAnimationKitTests/Info.plist index fb981fb..ba72822 100644 --- a/DKChainableAnimationKitTests/Info.plist +++ b/DKChainableAnimationKitTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.draveness.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme b/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme index 4ca0326..c7ed471 100644 --- a/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme +++ b/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -38,15 +38,18 @@ ReferencedContainer = "container:iOS Example.xcodeproj"> + + @@ -62,10 +65,10 @@ diff --git a/iOS Example/ViewController.swift b/iOS Example/ViewController.swift index b64b3b6..61483dc 100644 --- a/iOS Example/ViewController.swift +++ b/iOS Example/ViewController.swift @@ -32,7 +32,7 @@ class ViewController: UIViewController { func animateView(sender: UIButton) { sender.userInteractionEnabled = false - let purple = UIColor.purpleColor() + _ = UIColor.purpleColor() let green = UIColor.greenColor() v.animation.moveX(100).thenAfter(1.0).moveWidth(50).bounce.makeBackground(green).easeIn.anchorTopLeft.thenAfter(0.5).rotate(95).easeBack.thenAfter(0.5).moveY(300).easeIn.makeOpacity(0.0).animateWithCompletion(0.4, { From 32707709791a96e1158a239e98b943f3eb1cada5 Mon Sep 17 00:00:00 2001 From: Draveness Date: Fri, 18 Sep 2015 12:06:33 +0800 Subject: [PATCH 05/12] Update podspec --- DKChainableAnimationKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DKChainableAnimationKit.podspec b/DKChainableAnimationKit.podspec index 67fd05e..304608a 100644 --- a/DKChainableAnimationKit.podspec +++ b/DKChainableAnimationKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "DKChainableAnimationKit" - s.version = "1.5.0" + s.version = "1.6.0" s.summary = "Chainable Animation in Swift" s.description = <<-DESC From f4dfaa5e61c4c0d19460525ab8e6fb0a77bd75e6 Mon Sep 17 00:00:00 2001 From: Draveness Date: Thu, 17 Sep 2015 21:08:41 -0700 Subject: [PATCH 06/12] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 93826d6..12dae89 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This is a swift port for JHChainableAnimations by [jhurray](https://github.com/j # Demo -![language](https://img.shields.io/badge/Language-%20Swift%20-orange.svg) +![language](https://img.shields.io/badge/Language-%20Swift 2.0%20-orange.svg) [![Version](http://img.shields.io/cocoapods/v/DKChainableAnimationKit.svg?style=flat)](http://cocoadocs.org/docsets/DKChainableAnimationKit) ![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg) ![MIT License](https://img.shields.io/github/license/mashape/apistatus.svg) @@ -51,7 +51,7 @@ view.animation.makeScale(2.0).spring.animate(1.0) ``` use_frameworks! -pod "DKChainableAnimationKit", "~> 1.5.0" +pod "DKChainableAnimationKit", "~> 1.6.0" ``` # Installation with Carthage From 4b608649363f0887861fe102d6044de7ab20a50d Mon Sep 17 00:00:00 2001 From: Draveness Date: Sat, 5 Dec 2015 15:17:37 +0800 Subject: [PATCH 07/12] Updated 'makeFrame' method --- .../Classes/DKChainableAnimationKit+Frame.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift b/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift index c44fcea..00d589d 100644 --- a/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift +++ b/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift @@ -15,8 +15,7 @@ public extension DKChainableAnimationKit { } public func makeFrame(x: CGFloat, _ y: CGFloat, _ width: CGFloat, _ height: CGFloat) -> DKChainableAnimationKit { - let rect = CGRect(x: x, y: y, width: width, height: height) - return self.makeOrigin(x, y).makeBounds(rect) + return self.makeFrame(CGRect(x: x, y: y, width: width, height: height)) } public func makeBounds(rect: CGRect) -> DKChainableAnimationKit { From f0ef1ef025fe76ae9a05dc7fef33bc60dbdaf550 Mon Sep 17 00:00:00 2001 From: Draveness Date: Sat, 5 Dec 2015 15:26:52 +0800 Subject: [PATCH 08/12] Updated 'makeFrame' and added 'makeOrigin' 'makeCenter' methods --- .../DKChainableAnimationKit+Frame.swift | 19 ++++++++++--- iOS Example.xcodeproj/project.pbxproj | 1 + iOS Example/ViewController.swift | 28 ++++++++++--------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift b/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift index 00d589d..1fac92b 100644 --- a/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift +++ b/DKChainableAnimationKit/Classes/DKChainableAnimationKit+Frame.swift @@ -11,7 +11,7 @@ import Foundation public extension DKChainableAnimationKit { public func makeFrame(rect: CGRect) -> DKChainableAnimationKit { - return self.makeOrigin(rect.origin.x, rect.origin.y).makeBounds(rect) + return self.makeOrigin(rect.origin).makeSize(rect.size) } public func makeFrame(x: CGFloat, _ y: CGFloat, _ width: CGFloat, _ height: CGFloat) -> DKChainableAnimationKit { @@ -27,6 +27,10 @@ public extension DKChainableAnimationKit { } + public func makeSize(size: CGSize) -> DKChainableAnimationKit { + return self.makeSize(size.width, size.height) + } + public func makeSize(width: CGFloat, _ height: CGFloat) -> DKChainableAnimationKit { self.addAnimationCalculationAction { (view: UIView) -> Void in @@ -37,13 +41,17 @@ public extension DKChainableAnimationKit { } self.addAnimationCompletionAction { (view: UIView) -> Void in - let bounds = CGRect(x: 0, y: 0, width: width, height: height) - view.layer.bounds = bounds - view.bounds = bounds + view.layer.bounds.size = CGSize(width: width, height: height) + view.bounds.size = CGSize(width: width, height: height) } return self } + public func makeOrigin(origin: CGPoint) -> DKChainableAnimationKit { + return self.makeOrigin(origin.x, origin.y) + + } + public func makeOrigin(x: CGFloat, _ y: CGFloat) -> DKChainableAnimationKit { self.addAnimationCalculationAction { (view: UIView) -> Void in let positionAnimation = self.basicAnimationForKeyPath("position") @@ -58,7 +66,10 @@ public extension DKChainableAnimationKit { view.layer.position = newPosition } return self + } + public func makeCenter(center: CGPoint) -> DKChainableAnimationKit { + return self.makeCenter(center.x, center.y) } public func makeCenter(x: CGFloat, _ y: CGFloat) -> DKChainableAnimationKit { diff --git a/iOS Example.xcodeproj/project.pbxproj b/iOS Example.xcodeproj/project.pbxproj index 2d3322c..11a626c 100644 --- a/iOS Example.xcodeproj/project.pbxproj +++ b/iOS Example.xcodeproj/project.pbxproj @@ -207,6 +207,7 @@ 18CEB5B41B059B0300B6ACCB /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 0710; LastUpgradeCheck = 0630; ORGANIZATIONNAME = DeltaX; TargetAttributes = { diff --git a/iOS Example/ViewController.swift b/iOS Example/ViewController.swift index 61483dc..1697dec 100644 --- a/iOS Example/ViewController.swift +++ b/iOS Example/ViewController.swift @@ -11,7 +11,7 @@ import DKChainableAnimationKit class ViewController: UIViewController { - let v: UIView = UIView(frame: CGRect(x: 100, y: 150, width: 50, height: 50)) + let v: UIView = UIView(frame: CGRect(x: 10, y: 60, width: 1, height: 1)) override func viewDidLoad() { super.viewDidLoad() @@ -35,19 +35,21 @@ class ViewController: UIViewController { _ = UIColor.purpleColor() let green = UIColor.greenColor() - v.animation.moveX(100).thenAfter(1.0).moveWidth(50).bounce.makeBackground(green).easeIn.anchorTopLeft.thenAfter(0.5).rotate(95).easeBack.thenAfter(0.5).moveY(300).easeIn.makeOpacity(0.0).animateWithCompletion(0.4, { - self.v.layer.transform = CATransform3DMakeRotation(0, 0, 0, 1) - self.v.frame = CGRectMake(100, 150, 50, 50) - self.v.animation.makeOpacity(1.0).makeBackground(UIColor.blueColor()).animate(1.0) - self.v.layer.cornerRadius = 0 + v.animation.makeFrame(10, 60, 100, 100).animate(1.0) - - sender.animation.moveY(-50).easeInOutExpo.animate(1.1).animationCompletion = { - sender.userInteractionEnabled = true - }; - }) - - sender.animation.moveY(50).easeInOutExpo.animate(0.5) +// v.animation.moveX(100).thenAfter(1.0).moveWidth(50).bounce.makeBackground(green).easeIn.anchorTopLeft.thenAfter(0.5).rotate(95).easeBack.thenAfter(0.5).moveY(300).easeIn.makeOpacity(0.0).animateWithCompletion(0.4, { +// self.v.layer.transform = CATransform3DMakeRotation(0, 0, 0, 1) +// self.v.frame = CGRectMake(100, 150, 50, 50) +// self.v.animation.makeOpacity(1.0).makeBackground(UIColor.blueColor()).animate(1.0) +// self.v.layer.cornerRadius = 0 +// +// +// sender.animation.moveY(-50).easeInOutExpo.animate(1.1).animationCompletion = { +// sender.userInteractionEnabled = true +// }; +// }) +// +// sender.animation.moveY(50).easeInOutExpo.animate(0.5) } } From 481118c91f36ecdda04bb7045686c6567166b307 Mon Sep 17 00:00:00 2001 From: Draveness Date: Sat, 5 Dec 2015 15:27:38 +0800 Subject: [PATCH 09/12] Updated 'iOS Example Demo --- iOS Example/Base.lproj/Main.storyboard | 8 +++++--- iOS Example/ViewController.swift | 28 +++++++++++++------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/iOS Example/Base.lproj/Main.storyboard b/iOS Example/Base.lproj/Main.storyboard index 52ea29e..751e6de 100644 --- a/iOS Example/Base.lproj/Main.storyboard +++ b/iOS Example/Base.lproj/Main.storyboard @@ -1,13 +1,14 @@ - + - + + - + @@ -15,6 +16,7 @@ + diff --git a/iOS Example/ViewController.swift b/iOS Example/ViewController.swift index 1697dec..f2abbe9 100644 --- a/iOS Example/ViewController.swift +++ b/iOS Example/ViewController.swift @@ -35,21 +35,21 @@ class ViewController: UIViewController { _ = UIColor.purpleColor() let green = UIColor.greenColor() - v.animation.makeFrame(10, 60, 100, 100).animate(1.0) +// v.animation.makeFrame(10, 60, 100, 100).animate(1.0) -// v.animation.moveX(100).thenAfter(1.0).moveWidth(50).bounce.makeBackground(green).easeIn.anchorTopLeft.thenAfter(0.5).rotate(95).easeBack.thenAfter(0.5).moveY(300).easeIn.makeOpacity(0.0).animateWithCompletion(0.4, { -// self.v.layer.transform = CATransform3DMakeRotation(0, 0, 0, 1) -// self.v.frame = CGRectMake(100, 150, 50, 50) -// self.v.animation.makeOpacity(1.0).makeBackground(UIColor.blueColor()).animate(1.0) -// self.v.layer.cornerRadius = 0 -// -// -// sender.animation.moveY(-50).easeInOutExpo.animate(1.1).animationCompletion = { -// sender.userInteractionEnabled = true -// }; -// }) -// -// sender.animation.moveY(50).easeInOutExpo.animate(0.5) + v.animation.moveX(100).thenAfter(1.0).moveWidth(50).bounce.makeBackground(green).easeIn.anchorTopLeft.thenAfter(0.5).rotate(95).easeBack.thenAfter(0.5).moveY(300).easeIn.makeOpacity(0.0).animateWithCompletion(0.4, { + self.v.layer.transform = CATransform3DMakeRotation(0, 0, 0, 1) + self.v.frame = CGRectMake(100, 150, 50, 50) + self.v.animation.makeOpacity(1.0).makeBackground(UIColor.blueColor()).animate(1.0) + self.v.layer.cornerRadius = 0 + + + sender.animation.moveY(-50).easeInOutExpo.animate(1.1).animationCompletion = { + sender.userInteractionEnabled = true + }; + }) + + sender.animation.moveY(50).easeInOutExpo.animate(0.5) } } From 09f9756bd98525f183db360bf2e8d7fb528e9ef3 Mon Sep 17 00:00:00 2001 From: Draveness Date: Sat, 5 Dec 2015 15:27:58 +0800 Subject: [PATCH 10/12] Updated to recommand setting --- .../xcschemes/DKChainableAnimationKit.xcscheme | 2 +- iOS Example Tests/Info.plist | 2 +- iOS Example.xcodeproj/project.pbxproj | 7 ++++++- .../xcshareddata/xcschemes/iOS Example.xcscheme | 2 +- iOS Example/Info.plist | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/DKChainableAnimationKit.xcodeproj/xcshareddata/xcschemes/DKChainableAnimationKit.xcscheme b/DKChainableAnimationKit.xcodeproj/xcshareddata/xcschemes/DKChainableAnimationKit.xcscheme index 218c4d6..360190e 100644 --- a/DKChainableAnimationKit.xcodeproj/xcshareddata/xcschemes/DKChainableAnimationKit.xcscheme +++ b/DKChainableAnimationKit.xcodeproj/xcshareddata/xcschemes/DKChainableAnimationKit.xcscheme @@ -1,6 +1,6 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.draveness.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/iOS Example.xcodeproj/project.pbxproj b/iOS Example.xcodeproj/project.pbxproj index 11a626c..401e73c 100644 --- a/iOS Example.xcodeproj/project.pbxproj +++ b/iOS Example.xcodeproj/project.pbxproj @@ -208,7 +208,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0630; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = DeltaX; TargetAttributes = { 18CEB5BB1B059B0300B6ACCB = { @@ -356,6 +356,7 @@ COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -423,6 +424,7 @@ FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "iOS Example/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.draveness.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "iOS Example"; }; name = Debug; @@ -434,6 +436,7 @@ FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "iOS Example/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.draveness.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "iOS Example"; }; name = Release; @@ -452,6 +455,7 @@ ); INFOPLIST_FILE = "iOS Example Tests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.draveness.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "iOS ExampleTests"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOS Example.app/iOS Example"; }; @@ -467,6 +471,7 @@ ); INFOPLIST_FILE = "iOS Example Tests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.draveness.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "iOS ExampleTests"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOS Example.app/iOS Example"; }; diff --git a/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme b/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme index c7ed471..1384a93 100644 --- a/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme +++ b/iOS Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme @@ -1,6 +1,6 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.draveness.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName From f264330078a3f2af84a8e00bd866fb9299554912 Mon Sep 17 00:00:00 2001 From: Draveness Date: Sun, 6 Dec 2015 11:56:57 +0800 Subject: [PATCH 11/12] Fixed UIColor components problem when initialize with 'UIColor(white: alpha:' --- .../Classes/DKKeyFrameAnimation.swift | 16 ++++++++--- iOS Example/ViewController.swift | 28 +++++++++---------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/DKChainableAnimationKit/Classes/DKKeyFrameAnimation.swift b/DKChainableAnimationKit/Classes/DKKeyFrameAnimation.swift index 4af2751..351cb50 100644 --- a/DKChainableAnimationKit/Classes/DKKeyFrameAnimation.swift +++ b/DKChainableAnimationKit/Classes/DKKeyFrameAnimation.swift @@ -33,10 +33,18 @@ public class DKKeyFrameAnimation: CAKeyframeAnimation { if valueIsKindOf(NSNumber) { self.values = self.valueArrayFor(startValue: CGFloat(fromValue.floatValue), endValue: CGFloat(toValue.floatValue)) as [AnyObject] } else if valueIsKindOf(UIColor) { - let fromColor = self.fromValue.CGColor - let toColor = self.toValue.CGColor - let fromComponents = CGColorGetComponents(fromColor) - let toComponents = CGColorGetComponents(toColor) + var fromColor = self.fromValue + var toColor = self.toValue + if CGColorGetNumberOfComponents(fromColor.CGColor) == 2 { + let fromComponents = CGColorGetComponents(fromColor.CGColor) + fromColor = UIColor(red: fromComponents[0], green: fromComponents[0], blue: fromComponents[0], alpha: fromComponents[1]) + } + if CGColorGetNumberOfComponents(toColor.CGColor) == 2 { + let toComponents = CGColorGetComponents(toColor.CGColor) + toColor = UIColor(red: toComponents[0], green: toComponents[0], blue: toComponents[0], alpha: toComponents[1]) + } + let fromComponents = CGColorGetComponents(fromColor.CGColor) + let toComponents = CGColorGetComponents(toColor.CGColor) let redValues = self.valueArrayFor(startValue: fromComponents[0], endValue: toComponents[0]) as! [CGFloat] let greenValues = self.valueArrayFor(startValue: fromComponents[1], endValue: toComponents[1]) as! [CGFloat] diff --git a/iOS Example/ViewController.swift b/iOS Example/ViewController.swift index f2abbe9..1697dec 100644 --- a/iOS Example/ViewController.swift +++ b/iOS Example/ViewController.swift @@ -35,21 +35,21 @@ class ViewController: UIViewController { _ = UIColor.purpleColor() let green = UIColor.greenColor() -// v.animation.makeFrame(10, 60, 100, 100).animate(1.0) + v.animation.makeFrame(10, 60, 100, 100).animate(1.0) - v.animation.moveX(100).thenAfter(1.0).moveWidth(50).bounce.makeBackground(green).easeIn.anchorTopLeft.thenAfter(0.5).rotate(95).easeBack.thenAfter(0.5).moveY(300).easeIn.makeOpacity(0.0).animateWithCompletion(0.4, { - self.v.layer.transform = CATransform3DMakeRotation(0, 0, 0, 1) - self.v.frame = CGRectMake(100, 150, 50, 50) - self.v.animation.makeOpacity(1.0).makeBackground(UIColor.blueColor()).animate(1.0) - self.v.layer.cornerRadius = 0 - - - sender.animation.moveY(-50).easeInOutExpo.animate(1.1).animationCompletion = { - sender.userInteractionEnabled = true - }; - }) - - sender.animation.moveY(50).easeInOutExpo.animate(0.5) +// v.animation.moveX(100).thenAfter(1.0).moveWidth(50).bounce.makeBackground(green).easeIn.anchorTopLeft.thenAfter(0.5).rotate(95).easeBack.thenAfter(0.5).moveY(300).easeIn.makeOpacity(0.0).animateWithCompletion(0.4, { +// self.v.layer.transform = CATransform3DMakeRotation(0, 0, 0, 1) +// self.v.frame = CGRectMake(100, 150, 50, 50) +// self.v.animation.makeOpacity(1.0).makeBackground(UIColor.blueColor()).animate(1.0) +// self.v.layer.cornerRadius = 0 +// +// +// sender.animation.moveY(-50).easeInOutExpo.animate(1.1).animationCompletion = { +// sender.userInteractionEnabled = true +// }; +// }) +// +// sender.animation.moveY(50).easeInOutExpo.animate(0.5) } } From 6e6ac674205fe8e414250044f2555b08cdd54b28 Mon Sep 17 00:00:00 2001 From: Kassem Wridan Date: Sun, 27 Mar 2016 11:59:47 +0100 Subject: [PATCH 12/12] Restored iOS Example animations - The sample app had parts of it's animation code commented out - The view is now also restored to it's original location to create a seamless animation replay --- iOS Example/ViewController.swift | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/iOS Example/ViewController.swift b/iOS Example/ViewController.swift index 1697dec..4d86ad4 100644 --- a/iOS Example/ViewController.swift +++ b/iOS Example/ViewController.swift @@ -11,7 +11,7 @@ import DKChainableAnimationKit class ViewController: UIViewController { - let v: UIView = UIView(frame: CGRect(x: 10, y: 60, width: 1, height: 1)) + let v: UIView = UIView(frame: CGRect(x: 10, y: 60, width: 50, height: 50)) override func viewDidLoad() { super.viewDidLoad() @@ -32,24 +32,21 @@ class ViewController: UIViewController { func animateView(sender: UIButton) { sender.userInteractionEnabled = false - _ = UIColor.purpleColor() let green = UIColor.greenColor() - v.animation.makeFrame(10, 60, 100, 100).animate(1.0) + v.animation.anchorTopLeft.moveX(100).easeInOutExpo.thenAfter(0.5).moveWidth(50).bounce.makeBackground(green).easeIn.anchorTopLeft.thenAfter(0.5).rotate(95).easeBack.thenAfter(0.5).moveY(300).easeIn.makeOpacity(0.0).animateWithCompletion(0.4, { + self.v.layer.transform = CATransform3DMakeRotation(0, 0, 0, 1) + self.v.frame = CGRectMake(10, 60, 50, 50) + self.v.animation.makeOpacity(1.0).makeBackground(UIColor.blueColor()).animate(1.0) + self.v.layer.cornerRadius = 0 -// v.animation.moveX(100).thenAfter(1.0).moveWidth(50).bounce.makeBackground(green).easeIn.anchorTopLeft.thenAfter(0.5).rotate(95).easeBack.thenAfter(0.5).moveY(300).easeIn.makeOpacity(0.0).animateWithCompletion(0.4, { -// self.v.layer.transform = CATransform3DMakeRotation(0, 0, 0, 1) -// self.v.frame = CGRectMake(100, 150, 50, 50) -// self.v.animation.makeOpacity(1.0).makeBackground(UIColor.blueColor()).animate(1.0) -// self.v.layer.cornerRadius = 0 -// -// -// sender.animation.moveY(-50).easeInOutExpo.animate(1.1).animationCompletion = { -// sender.userInteractionEnabled = true -// }; -// }) -// -// sender.animation.moveY(50).easeInOutExpo.animate(0.5) + + sender.animation.moveY(-50).easeInOutExpo.animate(1.1).animationCompletion = { + sender.userInteractionEnabled = true + }; + }) + + sender.animation.moveY(50).easeInOutExpo.animate(0.5) } }