GithubHelp home page GithubHelp logo

arthurbikmullin / resizable-navigation-bar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jinjian1991/resizable-navigation-bar

0.0 1.0 0.0 6.8 MB

Open source implementation of resizable navigation bars in iOS

License: Eclipse Public License 1.0

Objective-C 95.25% Ruby 4.75%

resizable-navigation-bar's Introduction

resizable-navigation-bar

Open source implementation of resizable navigation bars in iOS

This project was inspired by Level Money's shift to large navigation headers in iOS and Apple's inability to correctly support this functionality. We were unable to find any implementation, although much of the original research and inspiration behind this project came from edmentec (http://www.emdentec.com/blog/2014/2/25/hacking-uinavigationbar)

alt tag

How to Use

Replace UINavigationController with LVResizableNavigationController. Then, in any UIViewController that needs to modify the navigation height, implement the protocol LVResizableNavigationBarController.

** If you are using a storyboard, you will also need to change the navigation bar class to LVResizableNavigationBar.

The code was written in such a way that using LVResizableNavigationController without implementing the LVResizableNavigationBarController protocol will not cause any problems.

// Height for navigation bar -> should be larger than 44.
// If not implemented, 44 is assumed
- (CGFloat)resizableNavigationBarControllerNavigationBarHeight;

// Not required in order to change the BarTintColor but
// necessary if you want to animate color changes between pushes
- (UIColor *)resizableNavigationBarControllerNavigationBarTintColor;

// Optionally place a subview in the Navigation Bar.
// subview frame is determined by Navigation bar:
// {0, 44, screenWidth, resizableNavigationBarControllerNavigationBarHeight - 44}
- (UIView *)resizableNavigationBarControllerSubHeaderView;

Limitations

  • The code currently assumes a status bar of 20 pts (fixable).
  • Landscape mode is not yet supported
  • Navigation bar only works for flat colors, not images or gradients
  • Animations aren't flawless

How it Works

Feel free to read through the code. It is a bit hacky and could struggle in future versions of iOS.

  • The navigation bar is resized using sizeToFit and sizeThatFits.
  • The animations are all controlled by a custom navigation animation to override iOS default behavior.
  • NavigationItems are hidden at animation start, and show at animation complete.
  • We rely on changing the color of UINavigationController.view.backgroundColor, which is visible when the navigation bar is larger than 44 pts. This is why images are difficult to support
  • The navigation bar height changes in order to keep layouts sane and correct. This allows views to be designed in storyboard or programmatically without needed to know what height the navigation bar could become.

resizable-navigation-bar's People

Contributors

oddanderson avatar

Watchers

Artur Bikmullin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.