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.
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
.
func supplementary() -> EPSupplementary {
return EPSupplementary(
view: MyCustomView(),
topPadding: 10,
viewHeight: 140,
bottomPadding: 30)
}
func navBarCenter() -> EPNavBarCenter? {
return .image(UIImage(named: "sushi"), height: 60)
}
func navBarCenter() -> EPNavBarCenter? {
return .title("Or a Title String")
}
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")
})
}
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)]
- Install the latest version of Carthage
- Add this line to your
Cartfile
github "p-sun/ExpandableNavController" ~> 1.0.0
- Follow the Carthage installation instructions
Copy the ExpandableNavController
folder
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()
.