Latest1.0.2
Homepagehttps://github.com/levelmoney/resizable-navigation-bar
LicenseEclipse 1.0
Platformsios 8.0, requires ARC
FrameworksUIKit
Authors

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.

Latest podspec

{
    "name": "resizable-navigation-bar",
    "version": "1.0.2",
    "summary": "Resizable UINavigationBar for iOS8",
    "description": "                       With the use of a LVResizableNavigationController, view controllers can now set the height of the navigation bar dynamically.nn                       To use, create a LVResizableNavigationController instead of UINavigationController, which will handle presentation and animations between UIViewControllers with different screen sizes.n",
    "homepage": "https://github.com/levelmoney/resizable-navigation-bar",
    "license": "Eclipse 1.0",
    "authors": {
        "Todd Anderson": "[email protected]"
    },
    "source": {
        "git": "https://github.com/levelmoney/resizable-navigation-bar.git",
        "tag": "1.0.2"
    },
    "social_media_url": "https://twitter.com/levelmoney",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "ResizableNavigationBar/Classes/*",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This