khorbushko / SideMenu

Simple side menu for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SideMenu

Lightweight pod for inegration simple sideMenu to your iOS app.

Swift ICONKit-license Platform type

demo

Installation

Using CocoaPods:

Simply add the following line to your Podfile:

pod 'HKSideMenu'

This will download the SideMenu binaries and dependencies in Pods/ during your next pod install execution.

This is the recommended way to install a specific version of SideMenu.

Usage

  • Create Menu for SideMenu.

To do so, create UIViewController that conforms MenuPresentable. Override storyboardName - name for storyboard file in which Menu controller xib placed and controllerIdentifier - storyboard Id of controller. Below example for MenuController that placed inside Main.storyboard and have identifier MenuController

import UIKit

final class MenuController: UIViewController, MenuPresentable {

  static var storyboardName: String {
    return "Main"
  }

  static var controllerIdentifier: String {
    return String(describing: MenuController.self)
  }
}

Note: default implementation include next for controllerIdentifier:

  static var controllerIdentifier: String {
    return String(describing: self)
  }

demo

  • Create RootController for SideMenu.

This is controller, that will hold all content and side menu item.

For creating rootController you should create/use class RootSideMenuController. This class should be informed where he should look for Menu. To inform class about it - set sideMenu type to RootSideMenuAppearence.menuType before RootSideMenuController loaded:

RootSideMenuAppearence.menuType = MenuController.self

Full code:

import UIKit

final class MyRootController: RootSideMenuController {
  // MARK: - LifeCycle

  override func viewDidLoad() {
  	 // make sure this done before `super.viewDidLoad`, in other case you will receive assertion
    RootSideMenuAppearence.menuType = MenuController.self

    super.viewDidLoad()
  }
}

✅ That's it - you done! Build and run the project.

To control menu state use hideMenu and showMenu actions from RootSideMenuController.

Advanced configuration

User different options from RootSideMenuAppearence for controlling appearence of menu

  /// Side offset for menu - display visible gap when full menu isOpened
  ///
  /// Default - 60.0
  public static var openMenuOffset: CGFloat = 60

  /// Color which used for dimming content while side menu opened
  ///
  /// Default - UIColor.lightGray.withAlphaComponent(0.5)
  public static var dimmingViewColor: UIColor = UIColor.lightGray.withAlphaComponent(0.5)

  /// Indicate whenever we should used shadow on side menu while it's opened
  ///
  /// Default - true, enabled
  public static var showShadow: Bool = true

  /// Shadow color for side menu, used with `showShadow` option
  ///
  /// Default - UIColor.lightGray
  public static var shadowColor: UIColor = UIColor.lightGray

  /// Indicate whenever we should show side menu from left or right side
  ///
  /// Default - Show from right
  public static var showMenuOnRightSide: Bool = false

  /// Indicate whenever we should allow to perform damping pan for side menu when it comes to final position
  /// If enabled - make sure your side menu has some extended not clipped view
  ///
  /// Default - false, disabled
  public static var enablePanDamping: Bool = false

  /// Hold registered type for side menu
  public static var menuType: MenuPresentable.Type!

TODO

  • test
  • option to move content instead of menu overlapping
  • more appearence options
  • simo menu (from left and right sides)

Requirement

  • Xcode 10 or higher
  • iOS 11 or higher
  • Swift 5 or higher
  • Cocoapods

License

MIT licensed.

Contact

Have a question or an issue about CalendarView? Create an issue!

If you would like to contribute - just create a pull request.

About

Simple side menu for iOS

License:MIT License


Languages

Language:Swift 95.2%Language:Ruby 4.8%