开源实现 iOS 中可调整大小的导航栏
该项目受到了 Level Money转向 iOS 中的大导航标题以及苹果无法正确支持此功能的启发。我们无法找到任何实现,尽管该项目背后的许多原始研究和工作灵感来源于 edmentec (http://www.emdentec.com/blog/2014/2/25/hacking-uinavigationbar)
将 UINavigationController 替换为 LVResizableNavigationController。然后在任何需要修改导航高度的 UIViewController 中实现 LVResizableNavigationBarController 协议。
** 如果您正在使用 Storyboard,您还需要将导航栏类更改为 LVResizableNavigationBar。
代码以这种方式编写,即使不实现 LVResizableNavigationBarController 协议也不会有任何问题。
// 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;
请随意阅读代码。它有些“投机取巧”,可能在未来的 iOS 版本中会遇到问题。