

GitHub - marty-suzuki/TheAnimation: Type-safe CAAnimation wrapper. It makes prev...
source link: https://github.com/marty-suzuki/TheAnimation
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
TheAnimation
TheAnimation is Type-safe CAAnimation wrapper.
Introduction
For example, if you want to animate backgroundColor
with CABasicAnimation
, you need to consider type because fromValue property and so on are Any?
.
If you use BasicAnimation of TheAnimation
, you can animate backgroundColor
without considering type! (AnimationKeyPaths.backgroundColor
is AnimationKeyPath<CGColor>
type.)
Usage
The way of making an animation is almost similar CAAnimation
.
But you need to use animation.animate(in:)
method instead of using layer.add(_:forKey:)
.
let view = UIView() let animation = BasicAnimation(keyPath: .opacity) animation.fromValue = 0 animation.toValue = 1 animation.duration = 1 animation.animate(in: view)
animation.animate(in:)
returns AnimaitonCanceller
. You can cancel an animation with it.
let canceller = animation.animate(in: view) canceller.cancelAnimation()
Example
To run the example project, clone the repo, and open Example directory.
Correspondence Table
CAAnimation TheAnimation CAPropertyAnimation PropertyAnimation CABasicAnimation BasicAnimation CAKeyframeAnimation KeyframeAnimation CASpringAnimation SpringAnimation CATransition TransitionAnimation CAAnimationGroup AnimationGroupAdd new AnimationKeyPath
You can add AnimationKeyPath
like this.
extension AnimationKeyPaths { static let newKeyPath = AnimationKeyPath<CGFloat>(keyPath: "abcd") }
Requirements
- Xcode 9.3
- iOS 9 or greater
Installation
Carthage
If you’re using Carthage, simply add
TheAnimation to your Cartfile
:
github "marty-suzuki/TheAnimation"
CocoaPods
TheAnimation is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'TheAnimation'
Author
marty-suzuki, [email protected]
License
TheAnimation is available under the MIT license. See the LICENSE file for more info.
Recommend
-
13
Product Leadership is Hard by Marty Cagan BY Lisa Radel ON JANUARY 8, 2021
-
8
Product is Hard by Marty Cagan BY James Gadsby Peet ON JUNE 17, 2019
-
14
Marty Bent On Freedom, Reframing The Energy Debate And Bitcoin 2021 – HodlalertMarty Bent On Freedom, Reframing The Energy Debate And Bitcoin 2021...
-
6
SUNDAY REWIND: The root causes of product failure by Marty Cagan BY
-
9
Purdy with Marty Jones Posted Fri, 08 Apr 2022 16:00:00 +0000 Allen Wyma talks with Marty Jones, creator of Purdy. Purdy is an expe...
-
9
9 Comments - Add comment
-
7
Fireside chat with Marty Cagan BY Andres Phillips ON MAY 6, 2022
-
9
Home ...
-
7
Learnings from London: Marty Cagan on making products customers love BY Louron Pratt...
-
8
Fast CompanyLoginHelp Center
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK