Skip to content

Easy way to dynamically change UINavigationBar , implemented in swift

License

Notifications You must be signed in to change notification settings

peiweichen/SurfingNavigationBar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SurfingNavigationBar

Easy way to dynamically change UINavigationBar , implemented in swift2.2

What is it

This project is heavily inspired by LTNavigationBar. SurfingNavigationBar provides you a chance to use pure Swift alternative in your next app.

alt tag alt tag alt tag alt tag

Usage

Firstly drag SurfingNavigationBar.swift into your project.

The UINavigationBar Extension includes 4 methods to manage UINavigationBar's appearance

func surfing_setBackgroundColor(backgroundColor:UIColor)
func surfing_setElementsAlpha(alpha:CGFloat)
func surfing_setTranslationY(translationY:CGFloat)
func surfing_reset()

Usually you should implement below function to avoid any side effects:

override func viewWillDisappear(animated: Bool) {
   super.viewWillDisappear(animated)
   self.navigationController?.navigationBar.surfing_reset()
}

I have implement the demo app that can help understand SurfingNavigationBar in a very swift and clear way,check out demo app for more details.

Mechanism:

SurfingNavigationBar implement self.setBackgroundImage(UIImage(), forBarMetrics: .Default) which remove the original appearance of UINavigationBar and we add a overlayView:UIView on UINavigationBar in runtime.The color,alpha,transfromY of overlayView is the variables we're managing.

Requirements

Xcode 7.3 , Swift 2.2

Author

Peiwei Chen [email protected]
Blog

License

Copyright (c) 2016 Peiwei Chen [email protected]. See the LICENSE file for license rights and limitations (MIT).

About

Easy way to dynamically change UINavigationBar , implemented in swift

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages