From a11dca5a0bfd7ff86abf7169ca11d7408cb33a4f Mon Sep 17 00:00:00 2001 From: funzin Date: Thu, 5 Jul 2018 19:04:28 +0900 Subject: [PATCH 1/3] Add UIView and CALayer extension --- Sica.xcodeproj/project.pbxproj | 10 +++++++++- Sica/Source/CALayer+Sica.swift | 27 +++++++++++++++++++++++++++ Sica/Source/UIView+Sica.swift | 27 +++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 Sica/Source/CALayer+Sica.swift create mode 100644 Sica/Source/UIView+Sica.swift diff --git a/Sica.xcodeproj/project.pbxproj b/Sica.xcodeproj/project.pbxproj index b0013b9..5dc1294 100644 --- a/Sica.xcodeproj/project.pbxproj +++ b/Sica.xcodeproj/project.pbxproj @@ -23,6 +23,8 @@ 9D436C5A20E9E8F200A1B938 /* Sica.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4A60FE320ABC9890079871A /* Sica.framework */; }; 9D436C6620E9EA1E00A1B938 /* SicaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4A60FF120ABC9890079871A /* SicaTests.swift */; }; 9D436C6820E9EA1E00A1B938 /* Sica.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4A60FE320ABC9890079871A /* Sica.framework */; }; + D449535120EE1BAF004C8AB9 /* UIView+Sica.swift in Sources */ = {isa = PBXBuildFile; fileRef = D449535020EE1BAF004C8AB9 /* UIView+Sica.swift */; }; + D449535320EE1F20004C8AB9 /* CALayer+Sica.swift in Sources */ = {isa = PBXBuildFile; fileRef = D449535220EE1F20004C8AB9 /* CALayer+Sica.swift */; }; D4A60FED20ABC9890079871A /* Sica.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4A60FE320ABC9890079871A /* Sica.framework */; }; D4A60FF220ABC9890079871A /* SicaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4A60FF120ABC9890079871A /* SicaTests.swift */; }; D4A60FF420ABC9890079871A /* Sica.h in Headers */ = {isa = PBXBuildFile; fileRef = D4A60FE620ABC9890079871A /* Sica.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -66,6 +68,8 @@ 9D436C6120E9E93800A1B938 /* Info-tvOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-tvOS.plist"; sourceTree = ""; }; 9D436C6D20E9EA1E00A1B938 /* SicaTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SicaTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 9D436C6F20E9EA5000A1B938 /* Info-macOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-macOS.plist"; sourceTree = ""; }; + D449535020EE1BAF004C8AB9 /* UIView+Sica.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Sica.swift"; sourceTree = ""; }; + D449535220EE1F20004C8AB9 /* CALayer+Sica.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CALayer+Sica.swift"; sourceTree = ""; }; D4A60FE320ABC9890079871A /* Sica.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sica.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D4A60FE620ABC9890079871A /* Sica.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Sica.h; sourceTree = ""; }; D4A60FE720ABC9890079871A /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = ""; }; @@ -184,11 +188,13 @@ D4CB78C020AC2BDD003232F6 /* Source */ = { isa = PBXGroup; children = ( - D4CB78C420AC2BDD003232F6 /* Animator.swift */, D4CB78C520AC2BDD003232F6 /* AnimationKeyPaths.swift */, + D4CB78C420AC2BDD003232F6 /* Animator.swift */, D4CB78C120AC2BDD003232F6 /* CAAnimation+Extension.swift */, + D449535220EE1F20004C8AB9 /* CALayer+Sica.swift */, D4CB78C620AC2BDD003232F6 /* TimingFunction.swift */, D4CB78C220AC2BDD003232F6 /* Transition.swift */, + D449535020EE1BAF004C8AB9 /* UIView+Sica.swift */, ); path = Source; sourceTree = ""; @@ -511,6 +517,8 @@ D4CB78CB20AC2BDD003232F6 /* Transition.swift in Sources */, D4CB78CA20AC2BDD003232F6 /* CAAnimation+Extension.swift in Sources */, D4CB78CD20AC2BDD003232F6 /* Animator.swift in Sources */, + D449535320EE1F20004C8AB9 /* CALayer+Sica.swift in Sources */, + D449535120EE1BAF004C8AB9 /* UIView+Sica.swift in Sources */, D4CB78CE20AC2BDD003232F6 /* AnimationKeyPaths.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Sica/Source/CALayer+Sica.swift b/Sica/Source/CALayer+Sica.swift new file mode 100644 index 0000000..4dfbad0 --- /dev/null +++ b/Sica/Source/CALayer+Sica.swift @@ -0,0 +1,27 @@ +// +// CALayer+Sica.swift +// Sica-iOS +// +// Created by 中澤 郁斗 on 2018/07/05. +// Copyright © 2018年 中澤 郁斗. All rights reserved. +// + +import Foundation + +private let _animatorAssociatedKey = UnsafeMutablePointer.allocate(capacity: 1) + +extension CALayer { + public var sica: Animator { + set { + objc_setAssociatedObject(self, _animatorAssociatedKey, newValue, .OBJC_ASSOCIATION_ASSIGN) + } + get { + guard let animator = objc_getAssociatedObject(self, _animatorAssociatedKey) as? Animator else { + let animator = Animator(layer: self) + objc_setAssociatedObject(self, _animatorAssociatedKey, animator, .OBJC_ASSOCIATION_ASSIGN) + return animator + } + return animator + } + } +} diff --git a/Sica/Source/UIView+Sica.swift b/Sica/Source/UIView+Sica.swift new file mode 100644 index 0000000..1926774 --- /dev/null +++ b/Sica/Source/UIView+Sica.swift @@ -0,0 +1,27 @@ +// +// UIView+Sica.swift +// Sica-iOS +// +// Created by 中澤 郁斗 on 2018/07/05. +// Copyright © 2018年 中澤 郁斗. All rights reserved. +// + +import Foundation + +private let _animatorAssociatedKey = UnsafeMutablePointer.allocate(capacity: 1) + +extension UIView { + public var sica: Animator { + set { + objc_setAssociatedObject(self, _animatorAssociatedKey, newValue, .OBJC_ASSOCIATION_ASSIGN) + } + get { + guard let animator = objc_getAssociatedObject(self, _animatorAssociatedKey) as? Animator else { + let animator = Animator(view: self) + objc_setAssociatedObject(self, _animatorAssociatedKey, animator, .OBJC_ASSOCIATION_ASSIGN) + return animator + } + return animator + } + } +} From d920284bf2e5396211ed29ed1eb97b49c7fa26de Mon Sep 17 00:00:00 2001 From: funzin Date: Thu, 5 Jul 2018 19:04:45 +0900 Subject: [PATCH 2/3] User sica property --- Demo/SicaDemo/ViewController.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Demo/SicaDemo/ViewController.swift b/Demo/SicaDemo/ViewController.swift index 67fba5b..ba740d1 100644 --- a/Demo/SicaDemo/ViewController.swift +++ b/Demo/SicaDemo/ViewController.swift @@ -21,9 +21,7 @@ class ViewController: UIViewController { view.addSubview(sampleView) Animation: do { - let animator = Animator(view: sampleView, forKey: "sampleAnimation") - - animator.delay(4) + sampleView.sica.delay(4) .addBasicAnimation(keyPath: .positionY, from: 368, to: 380, duration: 0.5, timingFunction: .easeOutExpo) .addBasicAnimation(keyPath: .positionY, from: 380, to: 378, duration: 1.5, timingFunction: .easeInOutCubic) .addBasicAnimation(keyPath: .positionY, from: 378, to: 372, duration: 0.2, timingFunction: .easeOutCubic) From 43c70b9af148d09880596a55a394089bb4cea811 Mon Sep 17 00:00:00 2001 From: funzin Date: Thu, 5 Jul 2018 19:05:27 +0900 Subject: [PATCH 3/3] Update version 0.3.0 --- Sica.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sica.podspec b/Sica.podspec index 07b5d77..f0529d3 100644 --- a/Sica.podspec +++ b/Sica.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "Sica" - s.version = "0.2.0" + s.version = "0.3.0" s.summary = "Sica can execute various animations sequentially or parallely" s.homepage = "https://github.com/cats-oss/Sica" s.license = { :type => "MIT", :file => "LICENSE" }