To run the example project, clone the repo, and run pod install
from the Example directory first.
- iOS 9.0
- Swift 4.2
EachNavigationBar is available through CocoaPods or Carthage. To install it, simply add the following line to your Podfile or Cartfile:
pod 'EachNavigationBar'
github "Pircate/EachNavigationBar"
import EachNavigationBar
let nav = UINavigationController(rootViewController: vc)
nav.navigation.configuration.isEnabled = true
nav.navigation.configuration.titleTextAttributes = [.foregroundColor: UIColor.blue]
nav.navigation.configuration.barTintColor = UIColor.red
nav.navigation.configuration.shadowImage = UIImage(named: "shadow")
nav.navigation.configuration.setBackgroundImage(UIImage(named: "nav"), for: .any, barMetrics: .default)
nav.navigation.configuration.backItem = UINavigationController.Configuration.BackItem(style: .title("返回"))
nav.navigation.configuration.prefersLargeTitles = true
nav.navigation.configuration.largeTitle.displayMode = .always
navigation.bar -> EachNavigationBar -> UINavigationBar
navigation.item -> UINavigationItem
// hide navigation bar
navigation.bar.isHidden = true
// set bar alpha
navigation.bar.alpha = 0.5
// set title alpha
navigation.bar.setTitleAlpha(0.5)
// set barButtonItem alpha
navigation.bar.setTintAlpha(0.5)
// if barButtonItem is customView
navigation.item.leftBarButtonItem?.customView?.alpha = 0.5
// if barButtonItem customized tintColor
navigation.item.leftBarButtonItem?.tintColor = navigation.item.leftBarButtonItem?.tintColor?.withAlphaComponent(0.5)
// remove blur effect
navigation.bar.isTranslucent = false
// hides shadow image
navigation.bar.isShadowHidden = true
// set status bar style
navigation.bar.statusBarStyle = .lightContent
// set back bar button item
navigation.bar.backBarButtonItem = .init(style: .title("Back"), tintColor: .red)
// allow back
navigation.bar.backBarButtonItem.shouldBack = { item in
// do something
return false
}
// handler before back
navigation.bar.backBarButtonItem.willBack = {
// do something
}
// handler after back
navigation.bar.backBarButtonItem.didBack = {
// do something
}
// if you want change navigation bar position
navigation.bar.automaticallyAdjustsPosition = false
// navigation bar additional height
navigation.bar.additionalHeight = 14
// navigation bar additional view
navigation.bar.additionalView = UIView()
// item padding
navigation.bar.layoutPaddings = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8)
// shadow
navigation.bar.shadow = Shadow(
color: UIColor.black.cgColor,
opacity: 0.5,
offset: CGSize(width: 0, height: 3))
// enable
navigation.bar.prefersLargeTitles = true
// display mode
navigation.item.largeTitleDisplayMode = .always
// alpha
navigation.bar.setLargeTitleAlpha(0.5)
Pircate, [email protected]
EachNavigationBar is available under the MIT license. See the LICENSE file for more info.