Drawer view controller that easy to use!

Overview

KWDrawerController

Pod Version Pod Platform Pod License Swift

Drawer view controller that is easy to use!

Installation

CocoaPods (iOS 8+ projects)

KWDrawerController is available on CocoaPods. Add the following to your Podfile:

# Swift 3
pod 'KWDrawerController', '~> 3.7'

# Swift 4~
pod 'KWDrawerController', '~> 4.2'
pod 'KWDrawerController/RxSwift'        # with RxSwift extension

Manually

Simply drag and drop the DrawerController folder into your existing project.

Usage

Code

import UIKit

import KWDrawerController

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        
        let mainViewController   = MainViewController()
        let leftViewController   = LeftViewController()
        let rightViewController  = RightViewController()
        
        let drawerController     = DrawerController()

        drawerController.setViewController(mainViewController, .none)
        drawerController.setViewController(leftViewController, .left)
        drawerController.setViewController(rightViewController, .right)

        /// Customizing

        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.rootViewController = drawerController
        window?.makeKeyAndVisible()

        return true
    }
}

Storyboard

Storyboard

  1. Set DrawerController as the Custom Class of the Initial ViewController.

  2. Connect the DrawerEmbedLeftControllerSegue and/or the DrawerEmbedRightControllerSegue from DrawerController to your left/right controllers.

  3. Connect the DrawerEmbedMainControllerSegue from DrawerController to your main controller.

  4. Set the segue identifiers of both the inspector of DrawerController and the segues themselves.

Open / Close

/// Open
self.drawerController?.openSide(.left)
self.drawerController?.openSide(.right)

/// Close
self.drawerController?.closeSide()

Delegate

optional func drawerDidAnimation(
    drawerController: DrawerController,
    side: DrawerSide,
    percentage: Float
)

optional func drawerDidBeganAnimation(
    drawerController: DrawerController,
    side: DrawerSide
)

optional func drawerWillFinishAnimation(
    drawerController: DrawerController,
    side: DrawerSide
)

optional func drawerWillCancelAnimation(
    drawerController: DrawerController,
    side: DrawerSide
)

optional func drawerDidFinishAnimation(
    drawerController: DrawerController,
    side: DrawerSide
)

optional func drawerDidCancelAnimation(
    drawerController: DrawerController,
    side: DrawerSide
)

Customizing

Transition

DrawerTransition is a module that determines the rendering direction to move the Drawer. It is implemented by inheriting DrawerTransition.

  • DrawerSlideTransition

DrawerSlideTransition

  • DrawerScaleTransition
    • Use is not recommended.
  • DrawerParallaxTransition

DrawerParallaxTransition

  • DrawerFloatTransition
    • When using the Transition, Overflow Transition should also use DrawerFloatTransition.

DrawerFloatTransition

  • DrawerFoldTransition

DrawerFoldTransition

  • DrawerSwingTransition

DrawerSwingTransition

  • DrawerZoomTransition

DrawerZoomTransition

Overflow Transition

Overflow Transition be used when Transition beyond the open range of the drawer.

  • DrawerSlideTransition
  • DrawerScaleTransition
    • This is natural when used with DrawerSlideTransition, DrwaerParallaxTransition, DrawerFoldTransition, and DrawerSwingTransition.

DrawerScaleTransition

  • DrawerParallaxTransition
  • DrawerFloatTransition
    • When using the Overflow Transition, Transition should also use DrawerFloatTransition.
  • DrawerFoldTransition
    • Use is not recommended.
  • DrawerSwingTransition
    • Use is not recommended.
  • DrawerZoomTransition

Animator

Animator is a module that controls the speed of moving a drawer. It is implemented by inheriting DrawerAnimator or DrawerTickAnimator.

  • DrawerLinearAnimator
  • DrawerCurveEaseAnimator
  • DrawerSpringAnimator
  • DrawerCubicEaseAnimator
  • DrawerQuadEaseAnimator
  • DrawerQuartEaseAnimator
  • DrawerQuintEaseAnimator
  • DrawerCircEaseAnimator
  • DrawerExpoEaseAnimator
  • DrawerSineEaseAnimator
  • DrawerElasticEaseAnimator
  • DrawerBackEaseAnimator
  • DrawerBounceEaseAnimator

Options

public var isTapToClose: Bool
public var isGesture: Bool
public var isAnimation: Bool
public var isOverflowAnimation: Bool
public var isShadow: Bool
public var isFadeScreen: Bool
public var isBlur: Bool
public var isEnable: Bool

Changelog

  • 1.0 First Release.
  • 1.1 Bug Fix, Add animations.
  • 2.0 Refactoring.
  • 2.1 Bug Fix, Update animation.
  • 2.2 Fix animation, and some bugs.
  • 3.0 Written in Swift 3.0
  • 3.1 Fix Access Control issues on DrawerController.
  • 3.2 Fix Access Control issues on Transition.
  • 3.3 Fix Access Control issues on initializer.
  • 3.4 Remove debug log.
  • 3.5 Fixed bug where touch ignores is not applied for "Absolute Controller".
  • 3.6 Fixed an occurs issue while the drawer was open and layout changing.
  • 3.6.1 Fixed layout issue when rotate device.
  • 3.7 Fixed not updating issues on properties.
  • 4.0 Support Swift 4.
  • 4.1 Implement new flag that enables direction auto-switching.
  • 4.1.1 Support RxSwift(If you want).
  • 4.1.2
    • Fix issues on auto layout of child view controllers.
    • Replace naming.
    • Implement getViewController method.
    • Reduce cloning size.
  • 4.1.3
    • Fix crashed on load. (#12)
  • 4.1.4
    • Add state methods to delegate. (#16)
    • Fix access control issues. (#18)
    • Fixed DrawerFloatTransition bug. (#20)
    • DrawerController incorrectly manages lifecycles of child controllers. (#21 #22)
  • 4.1.5
    • Code and performance improvements and bug fixes. (#24 @rivera-ernesto)
  • 4.1.6
    • Fix transition bugs.
    • Fix gesture not working bugs.
    • Fix right drawer placement on iPads (#28 @rivera-ernesto)
  • 4.2
    • Support swift 4.2. (#31)

⚠️ Requirements

  • iOS 8.0+
  • Swift 3.0+

🔑 License

KWDrawerController is under MIT license. See the LICENSE file for more info.

Comments
  • Use in Objective-C project

    Use in Objective-C project

    Hi Kawoou,

    I'm using your framework through CocoaPods, I use it exactly as your instruction, but storyboard failed to init DrawerController and returns a plain UIViewController as the initial ViewController. Do you happen to know what's the issue here? Thank you so much in advance!

    2018-01-16 6 26 29 2018-01-16 6 26 35 2018-01-16 6 26 43 2018-01-16 6 26 48
    opened by andyden9 13
  • drawerController is null in viewWillDisappear and viewDidDisappear

    drawerController is null in viewWillDisappear and viewDidDisappear

    Extension property drawerController of UIViewController returns nil when I'm trying to access it in viewWillDisappear and viewDidDisappear methods of my view controller. Could you please explain this behaviour if it's correct or fix it if there is some bug?

    opened by Serproger 12
  • Slide animation bug

    Slide animation bug

    Hi, I am seeing a random bug that is reproducible only on a device (tested on iPhone 5S and 7) I am using your example, without any modifications. The issue is that sometimes, when I press the button to open the right drawer (transition is set to Slide), the drawer opens up fine, but sometimes the slide animation stutters and the side viewcontroller is offset to the left of the screen (notice that the main viewcontroller underneath it remains at its initial position)

    right wrong

    opened by bdobreav 5
  • Crashed on load

    Crashed on load

    Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<KWDrawerController.DrawerController: 0x7f9e23978a00>)

    screen shot 2018-01-29 at 2 01 48 am
    opened by jeffayan 5
  • When closing a side panel presented using DrawerFloatTransition, the primary view is sometimes re-presented offset to the left

    When closing a side panel presented using DrawerFloatTransition, the primary view is sometimes re-presented offset to the left

    When closing a side panel that has been presented using a DrawerFloatTransition, the main view controller is not always restored properly and is instead drawn offset to the left by approximately 30 pixels. This creates a visual defect in the UI. Subsequent open / close of the side panel will exacerbate the situation, eventually causing the primary view to become unusable.

    See images below:

    one two three

    opened by ttupper92618 3
  • Unknown class KWDrawerController in Interface Builder file.

    Unknown class KWDrawerController in Interface Builder file.

    First of all thanks for the great library.

    I am having an issue, when i set Custom Class to "KWDrawerController" via story board there is no build issue only the console show this message "Unknown class KWDrawerController in Interface Builder file."

    I have removed the libs via pods and installed many times but still the same issue.

    Hoping for quick response.

    Thanks.

    opened by husnaintahir 3
  • Unable to get delegates to fire

    Unable to get delegates to fire

    Is there an example of using the delegates somewhere? I'm having trouble getting any delegate method to fire, and I badly need to be able to respond to drawer state as it changes.

    opened by ttupper92618 2
  • Using DrawerSlideTransition should resize the side view controllers to the available width

    Using DrawerSlideTransition should resize the side view controllers to the available width

    First off, really good work, it's a really clear project and easy to setup!

    I have a suggestion: when using a DrawerSlideTransition, since no background is visible (like DrawerFloatTransition for instance), it would be great if the child view controllers were resized to fit the available width.

    I have been able to make this by updating a bit DrawerContent.swift :

        internal func updateView() {
            let width = CGFloat(drawerWidth)
            contentView.frame.size.width = width
            drawerOffset = 0.0
            
            guard let superView = contentView.superview else { return }
            if drawerSide == .right {
                drawerOffset = superView.frame.width - width
            }
            viewController.view.frame = CGRect(
                x: 0,
                y: 0,
                width: width,
                height: superView.frame.height
            )
        }
    

    This may not be perfect to obtain the needed behaviour, and this affects all other transitions. Would you know a way to achieve this behaviour with a custom transition or a an additional setting?

    I also noticed it's not possible de create custom transitions because the methods of DrawerTransition are not marked open.

    opened by dvkch 2
  • Observe state with delegate

    Observe state with delegate

    Thanks for the library! It would be cool if there was a delegate protocol to preform actions on the drawer state changing rather than having to pass a completion handler in. For example, the following stubs:

    func drawerController?(willOpenSide side: DrawerSide)
    
    func drawerController?(willCloseSide side: DrawerSide)
    

    I'd be happy to submit a PR.

    Thanks, Charles

    opened by 0xch4z 2
  • Need Info

    Need Info

    When embedded in navigationController to drawerController , drawerController height is bottom of the navigation bar . Can i know how to overlap for navigation bar for drawercontroller ?

    opened by DeevD 1
  • Remove the gestures for a certain drawer

    Remove the gestures for a certain drawer

    How do I remove the gestures for a certain drawer?

    I will have a drawer with the main menu on all pages, and a drawer with an module submenu for a certain module...

    and I want only the main menu to be triggered by gestures...

    opened by ccosnean 1
  • Using a .right side menu, at first attempt of openSide(.right) results in a left side opening

    Using a .right side menu, at first attempt of openSide(.right) results in a left side opening

    With any gesture or touch after this misplacement, problem will resolve and .right side opens properly. I tried to debug very hard to contribute the project, yet I could not solve the puzzle. My guess: there might be an invalide size/frame reading occur before the (.right)view became visible. Thank you for opensourcing this project I was using it for over a year without any issues, then the specs changed and customer wants a right hand side menu:)

    Cheers,

    opened by ardarda 5
  • Q: Is possible add cornerRadius to main view controller?

    Q: Is possible add cornerRadius to main view controller?

    Good morning! First, thanks for this awesome lib!

    Someone can help me? Is possible add cornerRadius to main view controller when I click or swipe?

    Thanks

    opened by Lailan 2
  • No animation when replacing new controller to existing one in DrawerController

    No animation when replacing new controller to existing one in DrawerController

    Hi,

    I'm trying to change existing view controller by using setViewController(newController, for: .none) but it changes the controller without animation while the side menu is opened. Seems abit odd from user experience

    opened by kuoliangkwong 0
  • not working after pod install

    not working after pod install

    I installed it with pod ,used it with storyboard, it was not working, it displayed with DrawViewcontroller only. # Swift 4~ pod 'KWDrawerController', '~> 4.2' pod 'KWDrawerController/RxSwift' # with RxSwift extension

    But when I remove 'KWDrawerController' from podfile and drag the DrawerController folder to my project, it working well.

    Did i missed sth?

    opened by zhangyuepeng86 0
  • I can't trigger to open left or right side by button action.

    I can't trigger to open left or right side by button action.

    I followed instructions for storyboard and I set controllers correctly.

    class Example: UIViewController, DrawerControllerDelegate {

    override func viewDidLoad()  {
            super.viewDidLoad()
            self.drawerController?.delegate = self
            self.drawerController?.options.isAnimation = false
            self.drawerController?.setTransition(DrawerFloatTransition(), for: .left)
    }
    
    

    When I try to trigger open left side with this code block, drawerController throws nil error and crash.

    if self.drawerController!.drawerSide == .none {
                self.drawerController?.openSide(.left)
                    .subscribe()
                    .disposed(by: disposeBag)
            } else {
                self.drawerController?.closeSide()
                    .subscribe()
                    .disposed(by: disposeBag)
            }
    
    opened by GokmenAkar 7
Releases(v4.1.6)
Owner
Jungwon An
Jungwon An
SwiftySideMenu is a lightweight and easy to use side menu controller to add left menu and center view controllers with scale animation based on Pop framework.

SwiftySideMenu SwiftySideMenu is a lightweight, fully customizable, and easy to use controller to add left menu and center view controllers with scale

Hossam Ghareeb 84 Feb 4, 2022
Slide Menu (Drawer) in Swift

AKSwiftSlideMenu Slide Menu (Drawer) in Swift 5.0 Why to use a library everytime? Let's create our own Slide Menu in Swift 5.0 I have uploaded a video

Ashish Kakkad 281 Jan 5, 2023
A fun, easy-to-use tab bar navigation controller for iOS.

CircleBar Don’t you, sometimes, miss fun user interfaces? Truth is, we do. Sure, you can't use them in enterprise apps for obvious reasons, but if you

softhaus 786 Dec 25, 2022
A paging menu controller built from other view controllers placed inside a scroll view (like Spotify, Windows Phone, Instagram)

Unfortunately, life gets in the way sometimes and I won't be able to maintain this library any longer and upgrade this library to where it needs to be

null 5.2k Dec 31, 2022
XLPagerTabStrip is a Container View Controller that allows us to switch easily among a collection of view controllers

XLPagerTabStrip is a Container View Controller that allows us to switch easily among a collection of view controllers. Pan gesture can be used to move on to next or previous view controller. It shows a interactive indicator of the current, previous, next child view controllers.

xmartlabs 6.8k Dec 27, 2022
A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.

DTPagerController This is a control for iOS written in Swift. DTPagerController is simple to use and easy to customize. Screenshots Default segmented

Tung Vo 290 Nov 13, 2022
An easy to use and setup floating view for your app. 🎡

HHFloatingView An easy to use and setup floating view for your app. ?? Installation Manually - Add HHFloatingView/Source folder to your Project. And y

Hemang 95 Dec 15, 2022
A paging view controller with a highly customizable menu ✨

Getting Started | Customization | Installation Features Parchment lets you page between view controllers while showing any type of generic indicator t

Martin Rechsteiner 3k Jan 8, 2023
Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app small side menu. 🌶

RHSideButtons ?? Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app

Robert Herdzik 166 Nov 14, 2022
JNDropDownMenu - Easy to use TableView style dropdown menu.

Overview Swift version of https://github.com/dopcn/DOPDropDownMenu Easy to use TableView style dropdown menu. Setup The only thing you

Javal Nanda 65 Jun 27, 2021
An easy way to use `canPerformAction` for context menu in SwiftUI.

Use canPerformAction for TextField/Editor in SwiftUI You know how a TextField displays a set of context menu? It doesn't matter if it's UIKit or Swift

StuFF mc 5 Dec 18, 2021
Control your display's brightness from the macOS menu bar. Simple and easy to use.

MonitorControl Lite Control your display's brightness from the macOS menu bar. Simple and easy to use. About MonitorControl Lite is a simplified versi

null 62 Dec 11, 2022
Easy-to-use action menu

About Navigate Features Installation Usage Delegate Features Highly customizable support dark/light theme corner radius blured background width (iPad)

Vlad Karlugin 4 Jan 6, 2023
A side menu controller written in Swift for iOS

Description SideMenuController is a custom container view controller written in Swift which will display the main content within a center panel and th

Teo 1.2k Dec 29, 2022
Menu controller with expandable item groups, custom position and appearance animation written with Swift. Similar to ActionSheet style of UIAlertController.

Easy to implement controller with expanding menu items. Design is very similar to iOS native ActionSheet presentation style of a UIAlertController. As

Anatoliy Voropay 22 Dec 27, 2022
Custom transition between controllers. Settings controller for your iOS app.

SPLarkController About Transition between controllers to top. You can change animatable height after presentation controller. For presentation and dis

Ivan Vorobei 965 Dec 17, 2022
iOS Slide Menu Controller. It is written in pure swift.

SlideMenuController Requirements iOS 9+ Installation SlideMenuController is available through CocoaPods. To install it, simply add the following line

Myung gi son 40 Jan 16, 2022
slider view for choosing categories. add any UIView type as category item view. Fully customisable

CategorySliderView Horizontal or vertical slider view for choosing categories. Add any UIView type as category item view. Fully customisable Demo Inst

Cem Olcay 353 Nov 6, 2022
An iOS drop down menu with pretty animation and easy to customize.

IGLDropDownMenu An iOS drop down menu with pretty animation. Screenshot How To Use Use CocoaPods: pod 'IGLDropDownMenu' Manual Install: Just drap the

Galvin Li 1.2k Dec 27, 2022