Skip to content

A container view controller controlling a stack of cards.

Notifications You must be signed in to change notification settings

yourkarma/cards

Repository files navigation

Cards

A container view controller controlling a stack of cards.

example gif

Installation

Add the following to your Podfile:

pod "Cards",    git: "https://github.com/yourkarma/Cards"

Documentation

The primary class is the CardStackController. It supports pushing and popping any UIViewController subclass using respectively pushViewController:animated:completion: and popViewControllerAnimated:completion:. The first view controller pushed automatically becomes the rootViewController and fills the CardStackController's view.

Subsequent view controllers are pushed on top, the position of each card is determined by the internal CardAppearanceCalculator struct.

Like UITabBarController and UINavigationController a convenience cardStackController property is provided as an extension on UIViewController.

If side effects are necesarry before, during or after a transtion the CardStackTransitionCoordinator can be used to get notified of these events. Additionally, a delegate is provided on CardStackController that notifies when cards will appear/disappear and did appear/disappear.

The CardViewController uses an internal Card struct to keep track of which view controllers are being presented as cards and the associated view hierarchy and it's constraint. The card uses three custom UIKit subclasses to manage the appearance of the cards:

  • CardMaskShapeLayer a CAShapeLayer subclass that supports animating the path property. This is required to properly animated the mask when a trait change occurs.
  • CardMaskView a custom UIView subclass. Uses the CardMaskShapeLayer to create top rounded corners.
  • CardScrollView a custom UIScrollView subclass that prevents tracking when interacting with a button.

Example

An example application is included. It shows some of the basic usages of the CardStackController.

About

A container view controller controlling a stack of cards.

Resources

Stars

Watchers

Forks

Packages

No packages published