Commit b969bc18 by Daniel Dahan

issue-8: supporting 0 value in duration

parent 8fb973a5
...@@ -415,7 +415,6 @@ ...@@ -415,7 +415,6 @@
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.cosmicmind.Motion; PRODUCT_BUNDLE_IDENTIFIER = com.cosmicmind.Motion;
PRODUCT_MODULE_NAME = Motion; PRODUCT_MODULE_NAME = Motion;
...@@ -438,7 +437,6 @@ ...@@ -438,7 +437,6 @@
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.cosmicmind.Motion; PRODUCT_BUNDLE_IDENTIFIER = com.cosmicmind.Motion;
PRODUCT_MODULE_NAME = Motion; PRODUCT_MODULE_NAME = Motion;
......
...@@ -12,13 +12,13 @@ Motion offers a clean API to add animations to your views and layers. Simply pas ...@@ -12,13 +12,13 @@ Motion offers a clean API to add animations to your views and layers. Simply pas
## Animations ## Animations
Motion offers a clean API to add animations to your views and layers. Simply pass in animation structs with configurable parameters. Take a look at some examples below: Animations are not only beautiful to look at, they also tell the story of your application. Motion aims to give the building blocks necessary to create stunning animations without much effort. Motion's animation API will make maintenance a breeze and changes even easier. Simply pass in animation structs with configurable parameters. Take a look at some examples below:
[Download Sample Animations Project](https://github.com/CosmicMind/Samples/tree/development/Projects/Programmatic/Animations) [Download Sample Animations Project](https://github.com/CosmicMind/Samples/tree/development/Projects/Programmatic/Animations)
| Background Color | Corder Radius | Fade | Rotate | Size | Spring | | Background Color | Corder Radius | Fade | Rotate | Size | Spring |
| --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- |
| ![BackgroundColor](http://www.cosmicmind.com/motion/animations/background_color.gif) | ![Corner Radius](http://www.cosmicmind.com/motion/animations/corner_radius.gif) | ![Fade](http://www.cosmicmind.com/motion/animations/fade.gif) | ![Rotate](http://www.cosmicmind.com/motion/animations/rotate.gif) | ![Size](http://www.cosmicmind.com/motion/animations/size.gif) | ![Spring](http://www.cosmicmind.com/motion/animations/spring.gif) | | ![Background Color](http://www.cosmicmind.com/motion/animations/background_color.gif) | ![Corner Radius](http://www.cosmicmind.com/motion/animations/corner_radius.gif) | ![Fade](http://www.cosmicmind.com/motion/animations/fade.gif) | ![Rotate](http://www.cosmicmind.com/motion/animations/rotate.gif) | ![Size](http://www.cosmicmind.com/motion/animations/size.gif) | ![Spring](http://www.cosmicmind.com/motion/animations/spring.gif) |
| Border Color & Border Width | Depth | Position | Scale | Spin | Translate | | Border Color & Border Width | Depth | Position | Scale | Spin | Translate |
| --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- |
......
...@@ -141,10 +141,10 @@ fileprivate extension CALayer { ...@@ -141,10 +141,10 @@ fileprivate extension CALayer {
- Parameter completion: An optional completion block. - Parameter completion: An optional completion block.
*/ */
func startAnimations(_ animations: [MotionAnimation], completion: (() -> Void)? = nil) { func startAnimations(_ animations: [MotionAnimation], completion: (() -> Void)? = nil) {
let targetState = MotionAnimationState(animations: animations) let ts = MotionAnimationState(animations: animations)
Motion.delay(targetState.delay) { [weak self, Motion.delay(ts.delay) { [weak self,
targetState = targetState, ts = ts,
completion = completion] in completion = completion] in
guard let s = self else { guard let s = self else {
...@@ -152,108 +152,108 @@ fileprivate extension CALayer { ...@@ -152,108 +152,108 @@ fileprivate extension CALayer {
} }
var anims = [CABasicAnimation]() var anims = [CABasicAnimation]()
var duration = targetState.duration var duration = 0 == ts.duration ? 0.01 : ts.duration
if let v = targetState.backgroundColor { if let v = ts.backgroundColor {
let a = MotionCAAnimation.background(color: UIColor(cgColor: v)) let a = MotionCAAnimation.background(color: UIColor(cgColor: v))
a.fromValue = s.backgroundColor a.fromValue = s.backgroundColor
anims.append(a) anims.append(a)
} }
if let v = targetState.borderColor { if let v = ts.borderColor {
let a = MotionCAAnimation.border(color: UIColor(cgColor: v)) let a = MotionCAAnimation.border(color: UIColor(cgColor: v))
a.fromValue = s.borderColor a.fromValue = s.borderColor
anims.append(a) anims.append(a)
} }
if let v = targetState.borderWidth { if let v = ts.borderWidth {
let a = MotionCAAnimation.border(width: v) let a = MotionCAAnimation.border(width: v)
a.fromValue = NSNumber(floatLiteral: Double(s.borderWidth)) a.fromValue = NSNumber(floatLiteral: Double(s.borderWidth))
anims.append(a) anims.append(a)
} }
if let v = targetState.cornerRadius { if let v = ts.cornerRadius {
let a = MotionCAAnimation.corner(radius: v) let a = MotionCAAnimation.corner(radius: v)
a.fromValue = NSNumber(floatLiteral: Double(s.cornerRadius)) a.fromValue = NSNumber(floatLiteral: Double(s.cornerRadius))
anims.append(a) anims.append(a)
} }
if let v = targetState.transform { if let v = ts.transform {
let a = MotionCAAnimation.transform(v) let a = MotionCAAnimation.transform(v)
a.fromValue = NSValue(caTransform3D: s.transform) a.fromValue = NSValue(caTransform3D: s.transform)
anims.append(a) anims.append(a)
} }
if let v = targetState.spin { if let v = ts.spin {
var a = MotionCAAnimation.spinX(v.0) var a = MotionCAAnimation.spin(x: v.x)
a.fromValue = NSNumber(floatLiteral: 0) a.fromValue = NSNumber(floatLiteral: 0)
anims.append(a) anims.append(a)
a = MotionCAAnimation.spinY(v.1) a = MotionCAAnimation.spin(y: v.y)
a.fromValue = NSNumber(floatLiteral: 0) a.fromValue = NSNumber(floatLiteral: 0)
anims.append(a) anims.append(a)
a = MotionCAAnimation.spinZ(v.2) a = MotionCAAnimation.spin(z: v.z)
a.fromValue = NSNumber(floatLiteral: 0) a.fromValue = NSNumber(floatLiteral: 0)
anims.append(a) anims.append(a)
} }
if let v = targetState.position { if let v = ts.position {
let a = MotionCAAnimation.position(v) let a = MotionCAAnimation.position(v)
a.fromValue = NSValue(cgPoint: s.position) a.fromValue = NSValue(cgPoint: s.position)
anims.append(a) anims.append(a)
} }
if let v = targetState.opacity { if let v = ts.opacity {
let a = MotionCAAnimation.fade(v) let a = MotionCAAnimation.fade(v)
a.fromValue = s.value(forKeyPath: MotionAnimationKeyPath.opacity.rawValue) ?? NSNumber(floatLiteral: 1) a.fromValue = s.value(forKeyPath: MotionAnimationKeyPath.opacity.rawValue) ?? NSNumber(floatLiteral: 1)
anims.append(a) anims.append(a)
} }
if let v = targetState.zPosition { if let v = ts.zPosition {
let a = MotionCAAnimation.zPosition(v) let a = MotionCAAnimation.zPosition(v)
a.fromValue = s.value(forKeyPath: MotionAnimationKeyPath.zPosition.rawValue) ?? NSNumber(floatLiteral: 0) a.fromValue = s.value(forKeyPath: MotionAnimationKeyPath.zPosition.rawValue) ?? NSNumber(floatLiteral: 0)
anims.append(a) anims.append(a)
} }
if let v = targetState.size { if let v = ts.size {
let a = MotionCAAnimation.size(v) let a = MotionCAAnimation.size(v)
a.fromValue = NSValue(cgSize: s.bounds.size) a.fromValue = NSValue(cgSize: s.bounds.size)
anims.append(a) anims.append(a)
} }
if let v = targetState.shadowPath { if let v = ts.shadowPath {
let a = MotionCAAnimation.shadow(path: v) let a = MotionCAAnimation.shadow(path: v)
a.fromValue = s.shadowPath a.fromValue = s.shadowPath
anims.append(a) anims.append(a)
} }
if let v = targetState.shadowColor { if let v = ts.shadowColor {
let a = MotionCAAnimation.shadow(color: UIColor(cgColor: v)) let a = MotionCAAnimation.shadow(color: UIColor(cgColor: v))
a.fromValue = s.shadowColor a.fromValue = s.shadowColor
anims.append(a) anims.append(a)
} }
if let v = targetState.shadowOffset { if let v = ts.shadowOffset {
let a = MotionCAAnimation.shadow(offset: v) let a = MotionCAAnimation.shadow(offset: v)
a.fromValue = NSValue(cgSize: s.shadowOffset) a.fromValue = NSValue(cgSize: s.shadowOffset)
anims.append(a) anims.append(a)
} }
if let v = targetState.shadowOpacity { if let v = ts.shadowOpacity {
let a = MotionCAAnimation.shadow(opacity: v) let a = MotionCAAnimation.shadow(opacity: v)
a.fromValue = NSNumber(floatLiteral: Double(s.shadowOpacity)) a.fromValue = NSNumber(floatLiteral: Double(s.shadowOpacity))
anims.append(a) anims.append(a)
} }
if let v = targetState.shadowRadius { if let v = ts.shadowRadius {
let a = MotionCAAnimation.shadow(radius: v) let a = MotionCAAnimation.shadow(radius: v)
a.fromValue = NSNumber(floatLiteral: Double(s.shadowRadius)) a.fromValue = NSNumber(floatLiteral: Double(s.shadowRadius))
anims.append(a) anims.append(a)
} }
if #available(iOS 9.0, *), let (stiffness, damping) = targetState.spring { if #available(iOS 9.0, *), let (stiffness, damping) = ts.spring {
for i in 0..<anims.count { for i in 0..<anims.count where nil != anims[i].keyPath {
let v = anims[i] let v = anims[i]
guard "cornerRadius" != v.keyPath else { guard "cornerRadius" != v.keyPath else {
...@@ -262,18 +262,21 @@ fileprivate extension CALayer { ...@@ -262,18 +262,21 @@ fileprivate extension CALayer {
let a = MotionCAAnimation.convert(animation: v, stiffness: stiffness, damping: damping) let a = MotionCAAnimation.convert(animation: v, stiffness: stiffness, damping: damping)
anims[i] = a anims[i] = a
if a.settlingDuration > duration {
duration = a.settlingDuration duration = a.settlingDuration
} }
} }
}
let g = Motion.animate(group: anims, duration: duration) let g = Motion.animate(group: anims, duration: duration)
g.fillMode = MotionAnimationFillModeToValue(mode: .forwards) g.fillMode = MotionAnimationFillModeToValue(mode: .both)
g.isRemovedOnCompletion = false g.isRemovedOnCompletion = false
g.timingFunction = targetState.timingFunction g.timingFunction = ts.timingFunction
s.animate(g) s.animate(g)
if let v = targetState.completion { if let v = ts.completion {
Motion.delay(duration, execute: v) Motion.delay(duration, execute: v)
} }
......
...@@ -43,7 +43,7 @@ public class MotionAnimation { ...@@ -43,7 +43,7 @@ public class MotionAnimation {
public extension MotionAnimation { public extension MotionAnimation {
/** /**
Animates the view's current background color to the Animates a view's current background color to the
given color. given color.
- Parameter color: A UIColor. - Parameter color: A UIColor.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
...@@ -55,7 +55,7 @@ public extension MotionAnimation { ...@@ -55,7 +55,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current border color to the Animates a view's current border color to the
given color. given color.
- Parameter color: A UIColor. - Parameter color: A UIColor.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
...@@ -67,7 +67,7 @@ public extension MotionAnimation { ...@@ -67,7 +67,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current border width to the Animates a view's current border width to the
given width. given width.
- Parameter width: A CGFloat. - Parameter width: A CGFloat.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
...@@ -79,7 +79,7 @@ public extension MotionAnimation { ...@@ -79,7 +79,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current corner radius to the Animates a view's current corner radius to the
given radius. given radius.
- Parameter radius: A CGFloat. - Parameter radius: A CGFloat.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
...@@ -91,7 +91,7 @@ public extension MotionAnimation { ...@@ -91,7 +91,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current transform (perspective, scale, rotate) Animates a view's current transform (perspective, scale, rotate)
to the given one. to the given one.
- Parameter _ transform: A CATransform3D. - Parameter _ transform: A CATransform3D.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
...@@ -103,21 +103,7 @@ public extension MotionAnimation { ...@@ -103,21 +103,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current perspective to the gievn one through Animates a view's current rotate to the given x, y,
a CATransform3D object.
- Parameter _ perspective: A CGFloat.
- Returns: A MotionAnimation.
*/
static func perspective(_ perspective: CGFloat) -> MotionAnimation {
return MotionAnimation {
var t = $0.transform ?? CATransform3DIdentity
t.m34 = 1.0 / -perspective
$0.transform = t
}
}
/**
Animates the view's current rotate to the given x, y,
and z values. and z values.
- Parameter x: A CGFloat. - Parameter x: A CGFloat.
- Parameter y: A CGFloat. - Parameter y: A CGFloat.
...@@ -134,7 +120,7 @@ public extension MotionAnimation { ...@@ -134,7 +120,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current rotate to the given point. Animates a view's current rotate to the given point.
- Parameter _ point: A CGPoint. - Parameter _ point: A CGPoint.
- Parameter z: A CGFloat, default is 0. - Parameter z: A CGFloat, default is 0.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
...@@ -153,7 +139,7 @@ public extension MotionAnimation { ...@@ -153,7 +139,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current spin to the given x, y, Animates a view's current spin to the given x, y,
and z values. and z values.
- Parameter x: A CGFloat. - Parameter x: A CGFloat.
- Parameter y: A CGFloat. - Parameter y: A CGFloat.
...@@ -167,7 +153,7 @@ public extension MotionAnimation { ...@@ -167,7 +153,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current spin to the given point. Animates a view's current spin to the given point.
- Parameter _ point: A CGPoint. - Parameter _ point: A CGPoint.
- Parameter z: A CGFloat, default is 0. - Parameter z: A CGFloat, default is 0.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
...@@ -208,7 +194,7 @@ public extension MotionAnimation { ...@@ -208,7 +194,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current translation to the given Animates a view's current translation to the given
x, y, and z values. x, y, and z values.
- Parameter x: A CGFloat. - Parameter x: A CGFloat.
- Parameter y: A CGFloat. - Parameter y: A CGFloat.
...@@ -222,7 +208,7 @@ public extension MotionAnimation { ...@@ -222,7 +208,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current translation to the given Animates a view's current translation to the given
point value (x & y), and a z value. point value (x & y), and a z value.
- Parameter _ point: A CGPoint. - Parameter _ point: A CGPoint.
- Parameter z: A CGFloat, default is 0. - Parameter z: A CGFloat, default is 0.
...@@ -233,7 +219,7 @@ public extension MotionAnimation { ...@@ -233,7 +219,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current position to the given point. Animates a view's current position to the given point.
- Parameter _ point: A CGPoint. - Parameter _ point: A CGPoint.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
*/ */
...@@ -250,7 +236,7 @@ public extension MotionAnimation { ...@@ -250,7 +236,7 @@ public extension MotionAnimation {
static var fadeOut = MotionAnimation.fade(0) static var fadeOut = MotionAnimation.fade(0)
/** /**
Animates the view's current opacity to the given one. Animates a view's current opacity to the given one.
- Parameter _ opacity: A Double. - Parameter _ opacity: A Double.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
*/ */
...@@ -261,7 +247,7 @@ public extension MotionAnimation { ...@@ -261,7 +247,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current zPosition to the given position. Animates a view's current zPosition to the given position.
- Parameter _ position: An Int. - Parameter _ position: An Int.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
*/ */
...@@ -272,7 +258,7 @@ public extension MotionAnimation { ...@@ -272,7 +258,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current size to the given one. Animates a view's current size to the given one.
- Parameter _ size: A CGSize. - Parameter _ size: A CGSize.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
*/ */
...@@ -283,7 +269,7 @@ public extension MotionAnimation { ...@@ -283,7 +269,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current shadow path to the given one. Animates a view's current shadow path to the given one.
- Parameter path: A CGPath. - Parameter path: A CGPath.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
*/ */
...@@ -294,7 +280,7 @@ public extension MotionAnimation { ...@@ -294,7 +280,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current shadow color to the given one. Animates a view's current shadow color to the given one.
- Parameter color: A UIColor. - Parameter color: A UIColor.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
*/ */
...@@ -305,7 +291,7 @@ public extension MotionAnimation { ...@@ -305,7 +291,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current shadow offset to the given one. Animates a view's current shadow offset to the given one.
- Parameter offset: A CGSize. - Parameter offset: A CGSize.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
*/ */
...@@ -316,7 +302,7 @@ public extension MotionAnimation { ...@@ -316,7 +302,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current shadow opacity to the given one. Animates a view's current shadow opacity to the given one.
- Parameter opacity: A Float. - Parameter opacity: A Float.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
*/ */
...@@ -327,7 +313,7 @@ public extension MotionAnimation { ...@@ -327,7 +313,7 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's current shadow radius to the given one. Animates a view's current shadow radius to the given one.
- Parameter radius: A CGFloat. - Parameter radius: A CGFloat.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
*/ */
...@@ -360,29 +346,8 @@ public extension MotionAnimation { ...@@ -360,29 +346,8 @@ public extension MotionAnimation {
} }
/** /**
Animates the view's contents rect to the given one. The duration of the view's animation. If a duration of 0 is used,
- Parameter rect: A CGRect. the value will be converted to 0.01, to give a close to zero value.
- Returns: A MotionAnimation.
*/
static func contents(rect: CGRect) -> MotionAnimation {
return MotionAnimation {
$0.contentsRect = rect
}
}
/**
Animates the view's contents scale to the given one.
- Parameter scale: A CGFloat.
- Returns: A MotionAnimation.
*/
static func contents(scale: CGFloat) -> MotionAnimation {
return MotionAnimation {
$0.contentsScale = scale
}
}
/**
The duration of the view's animation.
- Parameter _ duration: A TimeInterval. - Parameter _ duration: A TimeInterval.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
*/ */
......
...@@ -39,7 +39,7 @@ public struct MotionAnimationState { ...@@ -39,7 +39,7 @@ public struct MotionAnimationState {
public var transform: CATransform3D? public var transform: CATransform3D?
/// A reference to the spin tuple. /// A reference to the spin tuple.
public var spin: (CGFloat, CGFloat, CGFloat)? public var spin: (x: CGFloat, y: CGFloat, z: CGFloat)?
/// A reference to the opacity. /// A reference to the opacity.
public var opacity: Double? public var opacity: Double?
...@@ -53,12 +53,6 @@ public struct MotionAnimationState { ...@@ -53,12 +53,6 @@ public struct MotionAnimationState {
/// A reference to the zPosition. /// A reference to the zPosition.
public var zPosition: CGFloat? public var zPosition: CGFloat?
/// A reference to the contentsRect.
public var contentsRect: CGRect?
/// A reference to the contentsScale.
public var contentsScale: CGFloat?
/// A reference to the borderWidth. /// A reference to the borderWidth.
public var borderWidth: CGFloat? public var borderWidth: CGFloat?
......
...@@ -147,29 +147,73 @@ public extension MotionCAAnimation { ...@@ -147,29 +147,73 @@ public extension MotionCAAnimation {
/** /**
Creates a CABasicAnimation for the transform.rotate.x key path. Creates a CABasicAnimation for the transform.rotate.x key path.
- Parameter _ rotations: An optional CGFloat. - Parameter x: An optional CGFloat.
- Returns: A CABasicAnimation. - Returns: A CABasicAnimation.
*/ */
static func spinX(_ rotations: CGFloat) -> CABasicAnimation { static func spin(x: CGFloat) -> CABasicAnimation {
return MotionCAAnimation.createAnimation(keyPath: .rotateX, toValue: NSNumber(value: Double(CGFloat(Double.pi) * 2 * rotations))) return MotionCAAnimation.createAnimation(keyPath: .rotateX, toValue: NSNumber(value: Double(CGFloat(Double.pi) * 2 * x)))
} }
/** /**
Creates a CABasicAnimation for the transform.rotate.y key path. Creates a CABasicAnimation for the transform.rotate.y key path.
- Parameter _ rotations: An optional CGFloat. - Parameter y: An optional CGFloat.
- Returns: A CABasicAnimation. - Returns: A CABasicAnimation.
*/ */
static func spinY(_ rotations: CGFloat) -> CABasicAnimation { static func spin(y: CGFloat) -> CABasicAnimation {
return MotionCAAnimation.createAnimation(keyPath: .rotateY, toValue: NSNumber(value: Double(CGFloat(Double.pi) * 2 * rotations))) return MotionCAAnimation.createAnimation(keyPath: .rotateY, toValue: NSNumber(value: Double(CGFloat(Double.pi) * 2 * y)))
} }
/** /**
Creates a CABasicAnimation for the transform.rotate.z key path. Creates a CABasicAnimation for the transform.rotate.z key path.
- Parameter _ rotations: An optional CGFloat. - Parameter z: An optional CGFloat.
- Returns: A CABasicAnimation. - Returns: A CABasicAnimation.
*/ */
static func spinZ(_ rotations: CGFloat) -> CABasicAnimation { static func spin(z: CGFloat) -> CABasicAnimation {
return MotionCAAnimation.createAnimation(keyPath: .rotateZ, toValue: NSNumber(value: Double(CGFloat(Double.pi) * 2 * rotations))) return MotionCAAnimation.createAnimation(keyPath: .rotateZ, toValue: NSNumber(value: Double(CGFloat(Double.pi) * 2 * z)))
}
/**
Creates a CABasicAnimation for the transform.scale key path.
- Parameter xyz: A CGFloat.
- Returns: A CABasicAnimation.
*/
public static func scale(_ xyz: CGFloat) -> CABasicAnimation {
let a = CABasicAnimation(keyPath: .scale)
a.toValue = NSNumber(value: Double(xyz))
return a
}
/**
Creates a CABasicAnimation for the transform.scale.x key path.
- Parameter x: A CGFloat.
- Returns: A CABasicAnimation.
*/
public static func scale(x: CGFloat) -> CABasicAnimation {
let a = CABasicAnimation(keyPath: .scaleX)
a.toValue = NSNumber(value: Double(x))
return a
}
/**
Creates a CABasicAnimation for the transform.scale.y key path.
- Parameter y: A CGFloat.
- Returns: A CABasicAnimation.
*/
public static func scale(y: CGFloat) -> CABasicAnimation {
let a = CABasicAnimation(keyPath: .scaleY)
a.toValue = NSNumber(value: Double(y))
return a
}
/**
Creates a CABasicAnimation for the transform.scale.z key path.
- Parameter z: A CGFloat.
- Returns: A CABasicAnimation.
*/
public static func scale(z: CGFloat) -> CABasicAnimation {
let a = CABasicAnimation(keyPath: .scaleZ)
a.toValue = NSNumber(value: Double(z))
return a
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment