• Stars
    star
    224
  • Rank 177,766 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 6 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Type-safe CAAnimation wrapper. It makes preventing to set wrong type values.

TheAnimation

Platform Language Carthage Version License CI Status

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 AnimationGroup

Add new AnimationKeyPath

You can add AnimationKeyPath like this.

extension AnimationKeyPaths {
    static let newKeyPath = AnimationKeyPath<CGFloat>(keyPath: "abcd")
}

Handle animation did Start / Stop

You can handle animation did Start with func setAnimationDidStart(handler:). In addition, you can handle animation did Stop with func setAnimationDidStop(handler:).

let view = UIView()

let animation = BasicAnimation(keyPath: .opacity)
animation.fromValue = 0
animation.toValue   = 1
animation.duration  = 1

animation.setAnimationDidStart {
    // do something
}

animation.setAnimationDidStop { finished in
    // do something
}

animation.animate(in: view)

Requirements

  • Xcode 9.3
  • iOS 9 or greater
  • tvOS 9 or greater
  • macOS 10.11 or greater
  • Swift 4.2 (since 0.3.0)

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.

More Repositories

1

ReverseExtension

A UITableView extension that enables cell insertion from the bottom of a table view.
Swift
1,675
star
2

SAHistoryNavigationViewController

SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller. Support 3D Touch!
Swift
1,569
star
3

iOSDesignPatternSamples

This is Github user search demo app which made by many variety of design patterns. You can compare differences in MVC, MVP, MVVM and Flux.
Swift
690
star
4

URLEmbeddedView

URLEmbeddedView automatically caches the object that is confirmed the Open Graph Protocol.
Swift
650
star
5

SABlurImageView

You can use blur effect and it's animation easily to call only two methods.
Swift
557
star
6

MisterFusion

MisterFusion is Swift DSL for AutoLayout. It is the extremely clear, but concise syntax, in addition, can be used in both Swift and Objective-C. Support Safe Area and Size Class.
Swift
314
star
7

SAInboxViewController

UIViewController subclass inspired by "Inbox by google" animated transitioning.
Swift
297
star
8

SACollectionViewVerticalScalingFlowLayout

UICollectionViewLayout that performs scaling up and down automatically on disappearing cells, and applies UIDynamics.
Swift
272
star
9

SAParallaxViewControllerSwift

SAParallaxViewControllerSwift realizes parallax scrolling with blur effect. In addition, it realizes seamless opening transition.
Swift
260
star
10

MartyJunior

You can change tab contents with swipe gesture on middle of UITableView!!
Swift
245
star
11

GitHubSearchWithSwiftUI

SwiftUI and Combine based GitHubSearch example.
Swift
205
star
12

DuctTape

๐Ÿ“ฆ KeyPath dynamicMemberLookup based syntax sugar for Swift.
Swift
175
star
13

HoverConversion

HoverConversion realized vertical paging with UITableView. UIViewController will be paged when reaching top or bottom of UITableView contentOffset.
Swift
163
star
14

NoticeObserveKit

NoticeObserveKit is type-safe NotificationCenter wrapper.
Swift
150
star
15

FluxCapacitor

This is what makes the Flux design pattern possible.
Swift
123
star
16

MSAlertController

MSAlertController has same feature at UIAlertViewController.
Objective-C
117
star
17

Prex

๐Ÿ”Unidirectional data flow architecture with MVP and Flux combination for Swift
Swift
109
star
18

QiitaWithFluxSample

A sample project uses Flux and MVVM features with RxSwift.
Swift
104
star
19

Continuum

NotificationCenter based Lightweight UI / AnyObject binder.
Swift
80
star
20

Ricemill

๐ŸŒพ โ™ป๏ธ ๐Ÿš Unidirectional Input / Output framework with Combine. Supports both of SwiftUI and UIKit.
Swift
63
star
21

PickerButton

PickerButton is subclass of UIButton that presents UIPickerView in UIKeyboard.
Swift
44
star
22

SASecretCommandViewController

You can use secret command with swipe gesture and A, B button. Show a secret mode you want!
Swift
43
star
23

ArtShredder

๐Ÿ“ฑBanksy Shredder for iOS
Swift
42
star
24

SplittableViewKit

A cell of IndexPath(row: 0, section: 0) in UITableView is automatically moved to left view when device rotated.
Swift
37
star
25

UILayoutBuilder

An AutoLayout DSL that intuitive syntax and viewable hierarchy.
Swift
37
star
26

SAWaveToast

Show text with wave animated background and floating animation.
Swift
34
star
27

TicTacToe-SwiftUI

Unidirectional data flow tic-tac-toe sample with SwiftUI.
Swift
23
star
28

SafeAreaExtension

You can handle safeAreaInsets changes of every UIView.
Swift
20
star
29

SABlurImageViewObjc

Objective-C
19
star
30

AnyObservableObject

Swift
18
star
31

ReuseCellConfigure

You can configure ReusableCell without casting!
Swift
17
star
32

GitHubClientTestSample

A GitHub client sample for User Action Logs testing.
Swift
17
star
33

MOAlertController

Objective-C
15
star
34

ConnpassAttendanceChecker

An attendance checking iOS application for https://connpass.com
Swift
14
star
35

SimplestCounterSample

This is simplest Counter App written in many variety of design patterns.
Swift
14
star
36

MyFirstAndroidPractice

I had began learning Android App development since Aug 2021. This is my first Android app project for practice development.
Kotlin
11
star
37

GithubKitForSample

Swift
11
star
38

DiffMVPAndMVVM

MVP and MVVM implementations and test code sample.
Swift
9
star
39

YouTubeSampleWithMVP-DiffableDataSource

This is a YouTube like iOS app sample with the Model-View-Presenter pattern.
Swift
9
star
40

Connpass

Swift
8
star
41

LayoutGuaranteedView

LayoutGuaranteedView is a Phantom Type view holder. It guaranteed that a view had laid out after execute `guaranteeLayout` function.
Swift
8
star
42

Necom

๐Ÿˆ New concept of MVP with Swift
Swift
7
star
43

RxAnyDispatcher

A observer(or observable)-only `Dispatcher` that is used in Flux.
Swift
7
star
44

kmm-with-spm-buildtoolplugin-sample

Kotlin
6
star
45

QiitaApiClient

API client for http://qiita.com/.
Swift
6
star
46

LazyInitializedViewModelInjectionSample

Swift
4
star
47

iOSDC2022LightningTalkSample

Swift
3
star
48

unio-kt

๐Ÿ”„ kProperty based Unidirectional Input / Output framework with Flow.
Kotlin
2
star
49

ReusableView

Swift
1
star
50

LayeredLayout

Swift
1
star
51

ViewIsolatedViewController

Swift
1
star