Skip to content

Commit

Permalink
Merge pull request #5 from cats-oss/add-sica-extension
Browse files Browse the repository at this point in the history
Add sica extension
  • Loading branch information
Fumito Nakazawa authored Jul 5, 2018
2 parents c7eba3a + 43c70b9 commit 279b663
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 5 deletions.
4 changes: 1 addition & 3 deletions Demo/SicaDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Sica.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
10 changes: 9 additions & 1 deletion Sica.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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, ); }; };
Expand Down Expand Up @@ -66,6 +68,8 @@
9D436C6120E9E93800A1B938 /* Info-tvOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-tvOS.plist"; sourceTree = "<group>"; };
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 = "<group>"; };
D449535020EE1BAF004C8AB9 /* UIView+Sica.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Sica.swift"; sourceTree = "<group>"; };
D449535220EE1F20004C8AB9 /* CALayer+Sica.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CALayer+Sica.swift"; sourceTree = "<group>"; };
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 = "<group>"; };
D4A60FE720ABC9890079871A /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 = "<group>";
Expand Down Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions Sica/Source/CALayer+Sica.swift
Original file line number Diff line number Diff line change
@@ -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<UInt>.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
}
}
}
27 changes: 27 additions & 0 deletions Sica/Source/UIView+Sica.swift
Original file line number Diff line number Diff line change
@@ -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<UInt>.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
}
}
}

0 comments on commit 279b663

Please sign in to comment.