Latest 1.0.2
Homepage https://github.com/wsj2012/EasyNavigationbar
License MIT
Platforms ios 9.0, requires ARC
Authors

定制UINavigationBar样式,可全局统一设置默认样式,在各页面灵活定制自己的样式。

Setup Instructions

To integrate EasyNavigationBar into your Xcode project using CocoaPods, specify it in your Podfile:

pod ‘EasyNavigationBar’, and in your code add import EasyNavigationBar.

Manually

Add EasyNavigationBar.swift to your project.

Basic Examples

  • Normal style

ScreenShot

func setNavbarAppearance() {
    // 导航栏颜色
    navBarBarTintColor = .white
    // 导航栏透明度
    navBarBackgroundAlpha = 1
    // 导航栏两边按钮颜色
    navBarTintColor = .black
    // 导航栏上标题颜色
    navBarTitleColor = .black
    // 导航栏底部分割线是否隐藏
    navBarShadowImageHidden = true;
    // 状态栏是 default 还是 lightContent
    statusBarStyle = .default
}
  • Custom Style

baidu


private let HEADER_HEIGHT:CGFloat = 260
private let NAVBAR_COLORCHANGE_POINT:CGFloat = HEADER_HEIGHT - CGFloat(kNavBarBottom * 2)

func setNavbarAppearanc() {
    // 设置导航栏颜色
    navBar.barBackgroundColor = UIColor(red: 247/255.0, green: 247/255.0, blue: 247/255.0, alpha: 1.0)
    // 设置初始导航栏透明度
    navBar.easy_setBackgroundAlpha(alpha: 0)
    // 设置标题文字颜色
    navBar.titleLabelColor = UIColor.white
    navBar.easy_setRightButton(title: "设置", titleColor: .white)
    statusBarStyle = .lightContent
    navBar.onRightButtonDidClick = {

    }
}

// MARK: - ScrollViewDidScroll
extension ViewController
{
    func scrollViewDidScroll(_ scrollView: UIScrollView)
    {
        let offsetY = scrollView.contentOffset.y
        if (offsetY > NAVBAR_COLORCHANGE_POINT)
        {
            let alpha = (offsetY - NAVBAR_COLORCHANGE_POINT) / CGFloat(kNavBarBottom)
            navBar.easy_setBackgroundAlpha(alpha: alpha)
            navBar.easy_setTintColor(color: UIColor.black.withAlphaComponent(alpha))
            navBar.titleLabelColor = UIColor.black.withAlphaComponent(alpha)
            statusBarStyle = .default
        } else {
            navBar.easy_setBackgroundAlpha(alpha: 0)
            navBar.easy_setTintColor(color: .white)
            navBar.titleLabelColor = .white
            statusBarStyle = .lightContent
        }
    }
}

If you have questions, you can see demo.

Compatibility

  • Version 1.0.1 requires Swift 4.2 and Xcode 10.

Latest podspec

{
    "name": "EasyNavigationbar",
    "version": "1.0.2",
    "summary": "u5b9au5236UINavigationBaru6837u5f0fuff0cu53efu5168u5c40u7edfu4e00u8bbeu7f6eu9ed8u8ba4u6837u5f0fuff0cu5728u5404u9875u9762u7075u6d3bu5b9au5236u81eau5df1u7684u6837u5f0fu3002",
    "homepage": "https://github.com/wsj2012/EasyNavigationbar",
    "license": "MIT",
    "authors": {
        "wsj_2012": "[email protected]"
    },
    "source": {
        "git": "https://github.com/wsj2012/EasyNavigationbar.git",
        "tag": "1.0.2"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "EasyNavigationbarView/*.{swift}",
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This