Skip to content

Latest commit

 

History

History
105 lines (77 loc) · 3.53 KB

README.md

File metadata and controls

105 lines (77 loc) · 3.53 KB

ExpandableNavController

A animated navigation controller where each view controller can supply a supplementary views with custom heights. The supplmentary views, as well as buttons are provided by view controllers.

The navigation controller animates transitions between view controllers and different heights and widths.

Swift 5.

How to Use

EPNavController can be used just like a regular UINavigationController, programically or from storyboard.

let navController = EPNavController(rootViewController: MyRootViewController())

Each view controller optionally declare what goes into the navigation bar by conforming to EPNavControllerDelegate.

Supplementary View

func supplementary() -> EPSupplementary {
    return EPSupplementary(
        view: MyCustomView(),
        topPadding: 10,
        viewHeight: 140,
        bottomPadding: 30)
}

Navigation Bar Center Title or Image

func navBarCenter() -> EPNavBarCenter? {
    return .image(UIImage(named: "sushi"), height: 60)
}

func navBarCenter() -> EPNavBarCenter? {
    return .title("Or a Title String")
}

Left and Right buttons

func navBarLeft() -> EPBarButtonItem? {
    return EPBarButtonItem(title: "Left Button", didTapButton: {
        print("Left button tapped")
    })
}

func navBarRight() -> EPBarButtonItem? {
    return EPBarButtonItem(title: "Right Button", didTapButton: {
        print("Right button tapped")
    })
}

Customization

You can set colors, fonts, and sizing in EPNavController.appearance.

EPNavController.appearance.tintColor = .purple
EPNavController.appearance.backgroundColor = .white

EPNavController.appearance.navCornerRadius = 30
EPNavController.appearance.topNavFromLayoutGuide = 60

EPNavController.appearance.shadowColor = .lightGray
EPNavController.appearance.shadowOpacity = 0.4

EPNavController.appearance.titleTextAttributes = [
    NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17, weight: .semibold)]
EPNavController.appearance.backTextAttributes = [
    NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17)]

Installation

Carthage

  1. Install the latest version of Carthage
  2. Add this line to your Cartfile
github "p-sun/ExpandableNavController" ~> 1.0.0
  1. Follow the Carthage installation instructions

Manual

Copy the ExpandableNavController folder

Bonus - Method Swizzling 🎉

There's an example of how to Method Swizzle in Swift, which is to say, change the implementation of Apple's methods at runtime. This example replaces all color calls with a method to randomize the colors. Tap any view to randomize the colors of that view and all its subviews.

To use this on any app, copy the UIColor+Swizzling.swift file, and call ColorSwizzler.swizzle().