GithubHelp home page GithubHelp logo

james01 / cardnavigation Goto Github PK

View Code? Open in Web Editor NEW
48.0 3.0 4.0 1.34 MB

A navigation controller that displays its view controllers as an interactive stack of cards.

License: MIT License

Swift 95.74% Ruby 4.26%
swift ios cards navigation uikit transition interactive interruptible cocoapods navigation-controller card-appearance

cardnavigation's Introduction

CardNavigation

CocoaPods Platform

The easiest way to turn a navigation controller into an interactive stack of cards.

Highlights

  • ✅ Fully interactive and interruptible
  • ✅ Works seamlessly with scroll views
  • ✅ Supports changes in orientation
  • ✅ Can be used with or without storyboards
  • ✅ Written entirely in Swift using standard UIKit components

Example

Installation

CocoaPods

To install CardNavigation using CocoaPods, add the following line to your Podfile:

pod 'CardNavigation', '~> 1.1'

Swift Package Manager

To install CardNavigation using the Swift Package Manager, add the following value to your Package.swift:

dependencies: [
    .package(url: "https://github.com/james01/CardNavigation.git", .upToNextMajor(from: "1.1.0"))
]

Usage

Getting Started

CardNavigation consists of a single class: CardNavigationController. It behaves like a standard UINavigationController.

At the top of the file where you'd like to use a CardNavigationController, import CardNavigation.

import CardNavigation

Create an instance of CardNavigationController the way you would a regular UINavigationController.

let navController = CardNavigationController(rootViewController: SomeViewController())

When you push a view controller, it will automatically be displayed as an interactive card.

navController.pushViewController(AnotherViewController(), animated: true)

Background Color

The CardNavigationController's navigationBar is transparent by default. This allows the controller's background color to show through.

You may want to change the background color to reflect the theme of your app.

navController.view.backgroundColor = .systemTeal

Card Appearance

To change the card appearance, create a custom view class.

import UIKit

class MyCardBackgroundView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = .white

        layer.cornerRadius = 32
        layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
        layer.cornerCurve = .continuous

        layer.borderColor = UIColor.black.cgColor
        layer.borderWidth = 4
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

Then, create a subclass of CardNavigationController and override the cardBackgroundViewClass property to return your custom class.

import UIKit
import CardNavigation

class MyCardNavigationController: CardNavigationController {

    override var cardBackgroundViewClass: UIView.Type {
        return MyCardBackgroundView.self
    }
}

Author

James Randolph (@jamesrandolph01)

License

CardNavigation is released under the MIT license. See LICENSE for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.