Code Monkey home page Code Monkey logo

siderevealkit's Introduction

SideRevealKit

SideRevealKit is iOS Dynamic Framework for presenting UIViewController's on the left side behing another UIViewController. It is perfect for implementing side menus and at the same time minimalistic in its implementation. It provides the basic behaviour while leaving you to do the UI cistomizations, which sets it apart from libraries that provide the same functionality with many different styles already contained in the library. If you don't want to have reveal styles and code that is unused in your app, then this implementation is right for you.

Build using Swift 5, XCode 10.2, supports iOS 10.0+

Preview

Usage

You can use SideRevealKit from code and from storyboards.

  • setup from code:

    • in your AppDelegate import SideRevealKit
    • in your AppDelegate applicationDidFinishLaunching method add:
     window?.rootViewController = SideRevealViewController.shared
    
     // replace the paramater with your view controller 
     SideRevealViewController.shared.loadSideFrom(UITableViewController())
     
     // replace the paramater with your view controller
     SideRevealViewController.shared.loadFrontFrom(UIViewController())
    • When you want to reveal the side controller, you can call either: SideRevealViewController.shared.toggleReveal() or SideRevealViewController.shared.revealSide(_ reveal: Bool, animated: Bool)
  • setup from Storyboard:

    • Place new UIViewControler from your library inside the storyboard.
    • Set its class to SideRevealViewController from module SideRevealKit
    • make a manual storyboard segue "front reveal" (should be available in the popup menu) from SideRevealViewController to the view controller you want to be loaded on the front, with identifier "SideRevealKit-Front" and class FrontRevealSegue
    • make a manual storyboard segue "side reveal" (should be available in the popup menu) from SideRevealViewController to the view controller you want to be loaded on the side, with identifier "SideRevealKit-Side" and class SideRevealSegue
    • When you want to reveal the side controller, you can call either: SideRevealViewController.shared.toggleReveal() or SideRevealViewController.shared.revealSide(_ reveal: Bool, animated: Bool) from your code.

If you need more info, have a look at the example projects, there is one for storyboard setup and one for code setup.

Customisation

SideRevealControllers have the following properties that you can use to tweak their appearance:

// MARK: Public Settings

/// Property that controls how much the front(main) view controller is moved to the side on reveal.
///
/// On this property depends how wide your container for side controller's view will be.
@IBInspectable public var revealWidth: CGFloat = 250

/// Property that controls how much time is needed for the front(main)
/// view controller to move fully in order to reveal the side view controller.
@IBInspectable public var revealDuration: TimeInterval = 0.7

/// Property that controls the bounciness of the reveal action.
@IBInspectable public var revealDamping: CGFloat = 0.8

/// Used to set the color of the overlay that hides the front view on reveal.
@IBInspectable public var frontOverlayColor: UIColor = .clear

/// Used to set the alpha level of the overlay that hides the front view on reveal.
@IBInspectable public var frontOverlayAlpha: CGFloat = 0.7

/// This enables/disables the swipe to reveal gesture.
@IBInspectable  public  var revealOnSwipe = true

/// This defines the width of the stripe from which you can initiate the swipe to reveal gesture
/// as a percentage of the view controller's `view.bounds.width`.
@IBInspectable public var revealSwipeStartZone: CGFloat = 0.075

In addition to that, you can alter the SideRevealControler.view.backgroundColor, to match the design of your app. If You want to apply transformations, to either the front or the side view controller, you can access their container views from SideRevealViewController.shared.frontContainer and SideRevealViewController.shared.sideContainer and apply properties to them.

Example:

// enables shadow on the front view controller, which drops on the side container when revealed.
SideRevealViewController.shared.frontContainer.layer.shadowOpacity = 1

You can also set delegate to SideRevealControllers that will be notified when side reveal is happening.

/// Set of all callbacks for reveal state switching of `SideRevealViewController`.
///
/// If you want to receive those, set yourself as delegate of the `SideRevealViewController`.
@objc public protocol SideRevealViewControllerDelegate: AnyObject {

/// Called when `SideRevealViewController` is about to switch its state.
///
/// - Parameters:
/// - sideRevealViewController: reference to the `SideRevealViewController`.
/// - reveal: true if side controller will be shown, false if it will be hidden.
/// - animated: true if reveal action will be animated, false if not.
@objc optional func sideRevealViewController(_ sideRevealViewController: SideRevealViewController, willReveal reveal: Bool, animated: Bool)
}

Documentation

The project has webpage documentation inside /Documentation folder, generated with jazzy. You can open it from XCode by building Open Documentation target.

Installation

Carthage Installation

  1. In your Cartfile add github "stoqn4opm/SideRevealKit"
  2. Link the build framework with the target in your XCode project

For detailed instructions check the official Carthage guides here

Manual Installation

  1. Download the project and build the shared target called SideRevealKit
  2. Add the product in the list of "embed frameworks" list inside your project's target or create a work space with SideRevealKit and your project and link directly the product of SideRevealKit's target to your target "embed frameworks" list

Licence

The framework is licensed under MIT licence. For more information see file LICENCE

siderevealkit's People

Contributors

stoqn4opm avatar

Watchers

 avatar  avatar

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.