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

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

Setup Instructions

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

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

Manually

Just add YZTNavigationBar folder to your project.

Basic Examples

  • 1、Normal style

ScreenShot

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

baidu


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

        }
    }

// MARK: - ScrollViewDidScroll
extension YZTPersonalCenterViewController
{
    func scrollViewDidScroll(_ scrollView: UIScrollView)
    {
        let offsetY = scrollView.contentOffset.y
        if (offsetY > NAVBAR_COLORCHANGE_POINT)
        {
            let alpha = (offsetY - NAVBAR_COLORCHANGE_POINT) / CGFloat(kNavBarBottom)
            navBar.yzt_setBackgroundAlpha(alpha: alpha)
            navBar.yzt_setTintColor(color: UIColor.black.withAlphaComponent(alpha))
            navBar.titleLabelColor = UIColor.black.withAlphaComponent(alpha)
            statusBarStyle = .default
        }
        else
        {
            navBar.yzt_setBackgroundAlpha(alpha: 0)
            navBar.yzt_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": "YZTNavigationBar",
    "version": "1.0.3",
    "summary": "u5b9au5236UINavigationBaru6837u5f0fuff0cu53efu5168u5c40u7edfu4e00u8bbeu7f6eu9ed8u8ba4u6837u5f0fuff0cu5728u5404u9875u9762u7075u6d3bu5b9au5236u81eau5df1u7684u6837u5f0fu3002",
    "homepage": "https://github.com/wsj2012/YZTNavigationBar",
    "license": "MIT",
    "authors": {
        "wsj_2012": "[email protected]"
    },
    "source": {
        "git": "https://github.com/wsj2012/YZTNavigationBar.git",
        "tag": "1.0.3"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "YZTNavigationBar/*.{swift}",
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This