UINavigationController

UINavigationController

UINavigationBar

UIToolbar

UIBarItem

UIBarButtonItem


  1. 简介
    1. 导航效果图
    2. 导航控制器的对象管理
    3. 导航控制器内的视图
  2. Creating Navigation Controllers
  3. Accessing Items on the Navigation Stack
  4. Pushing and Popping Stack Items
  5. Configuring Navigation Bars
  6. Configuring Custom Toolbars
  7. Hiding the Navigation Bar
  8. Accessing the Delegate
  9. Action Method for Displaying View Controllers

1 简介

在开发app的过程中任何一个项目都会用到UINavigationController,这是一个很有用的控件,它主要控制界面的跳转和导航。

1.1 导航效果图

1.2 导航控制器的对象管理

1.3 导航控制器内的视图

2 Creating Navigation Controllers

/// 使用自定义的navigationBar和toolbar
///
/// - parameter navigationBarClass : AnyClass
/// - parameter toolbarClass : AnyClass
///
/// - returns: UINavigationController
public init(navigationBarClass: AnyClass?, toolbarClass: AnyClass?)


/// 初始化UINavigationController并指定根VC
///
/// - parameter rootViewController : UIViewController
///
/// - returns: UINavigationController
public init(rootViewController: UIViewController)

3 Accessing Items on the Navigation Stack

/// 顶部UIViewController
public var topViewController: UIViewController? { get } // The top view controller on the stack.
/// 当前UIViewController
public var visibleViewController: UIViewController? { get } // Return modal view controller if it exists. Otherwise the top view controller.

/// 当前UINavigationController管理的UIViewController
public var viewControllers: [UIViewController] // The current view controller stack.

/// 替换堆栈控件的[UIViewController]
///
/// - parameter viewControllers : 要替换的视图
/// - parameter animated : 是否动画替换
///
/// - returns: void
@available(iOS 3.0, *)
public func setViewControllers(viewControllers: [UIViewController], animated: Bool)

4 Pushing and Popping Stack Items

/// push进入下一个VC
///
/// - parameter viewController : UIViewController 目标VC
/// - parameter animated : Bool 是否动画跳转
///
/// - returns: void
public func pushViewController(viewController: UIViewController, animated: Bool)

/// pop回到上一个VC
///
/// - parameter animated : Bool 是否动画跳转
///
/// - returns: 当前UIViewController
public func popViewControllerAnimated(animated: Bool) -> UIViewController?

/// pop回到指定VC
///
/// - parameter viewController : UIViewController 目标VC
/// - parameter animated : Bool 是否动画跳转
///
/// - returns: 弹出的[UIViewController]
public func popToViewController(viewController: UIViewController, animated: Bool) -> [UIViewController]?

/// pop回到第一个VC
///
/// - parameter animated : Bool 是否动画跳转
///
/// - returns: 弹出的[UIViewController]
public func popToRootViewControllerAnimated(animated: Bool) -> [UIViewController]?

/// 手势滑动返回的手势
public var interactivePopGestureRecognizer: UIGestureRecognizer? { get }

5 Configuring Navigation Bars

/// 获取UINavigationBar
public var navigationBar: UINavigationBar { get }

/// 是否隐藏UINavigationBar
public var navigationBarHidden: Bool

/// 是否动画隐藏UINavigationBar
///
/// - parameter hidden : 是否隐藏
/// - parameter animated : 是否动画
///
/// - returns: void
public func setNavigationBarHidden(hidden: Bool, animated: Bool)

6 Configuring Custom Toolbars

/// 获取UIToolbar
@available(iOS 3.0, *)
public var toolbar: UIToolbar! { get }
/// 是否隐藏UIToolbar
@available(iOS 3.0, *)
public var toolbarHidden: Bool // Defaults to YES, i.e. hidden.

/// 是否动画隐藏UIToolbar
///
/// - parameter hidden : 是否隐藏
/// - parameter animated : 是否动画
///
/// - returns: void
@available(iOS 3.0, *)
public func setToolbarHidden(hidden: Bool, animated: Bool)

7 Hiding the Navigation Bar

/// 是否点击屏幕隐藏UINavigationBar
@available(iOS 8.0, *)
public var hidesBarsOnTap: Bool
/// 点击屏幕隐藏UINavigationBar的手势
@available(iOS 8.0, *)
unowned(unsafe) public var barHideOnTapGestureRecognizer: UITapGestureRecognizer { get }

/// 是否点击上下滑动隐藏UINavigationBar
@available(iOS 8.0, *)
public var hidesBarsOnSwipe: Bool
/// 滑动隐藏UINavigationBar的手势
@available(iOS 8.0, *)
public var barHideOnSwipeGestureRecognizer: UIPanGestureRecognizer { get }

/// 是否键盘打开时隐藏UINavigationBar
@available(iOS 8.0, *)
public var hidesBarsWhenKeyboardAppears: Bool

 /// 是否横屏隐藏UINavigationBar
@available(iOS 8.0, *)
public var hidesBarsWhenVerticallyCompact: Bool

8 Accessing the Delegate

/// 跳转监听
weak var delegate: UINavigationControllerDelegate?

9 Action Method for Displaying View Controllers

/// 和pushViewController:animated:相同的功能,可携带参数传递
///
/// - parameter vc : UIViewController
/// - parameter sender : 携带参数
///
/// - returns: void
func showViewController(_ vc: UIViewController, sender sender: AnyObject?)

 


其他

源代码

Swift

参考资料

UIKit Framework Reference

UINavigationController Class Reference

文档修改记录

时间描述
2016-01-09博文完成

版权所有

CSDN:http://blog.csdn.net/y550918116j

GitHub:https://github.com/937447974/Blog

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值