zoukankan      html  css  js  c++  java
  • UINavigationController

    知识点:

    1)UINavigationController

    2)UINavigationBar

    3)UINavigationItem

    4)UIToolBar

    ======================================================

    一、UINavigationController

     

    1、UINavigationController介绍

    1)UINavigationController是导航控制器,它通过栈的方式控制当前显示在屏幕上的是哪个控制器。

    2)它可以通过压入(push)和弹出(pop)来改变控制器的层次。

    3)自动提供返回(Back)按钮,以回到上一个压入的控制器,不需要额外编程

    4)UINavigationController会提供控制器切换的动画效果

    5)   UINavgationController通过栈的形式管理多个UIViewController(即多个界面)

    6)可以管理当前在导航条(navigationBar)上的导航按钮

    7)UINavgationController为每个接受它管理的UIViewController自动添加UINavigationBar

    8)包括四部分: 1⃣️.UINavigationController 

      2⃣️.UIViewController

        3⃣️.UINavigationBar

        4⃣️.UINavigationItem

    2、导航控制器的跳转

    1)pushViewController: animated:  跳转,切换到下一个视图控制器(压栈)

    2)popViewControllerAnimated:  返回上一层(出栈)

    3)popToRootViewControllerAnimated:  返回root视图控制器(根视图控制器)

    4)popToViewController:  animated:  返回到指定层

    5)   setViewControllers:(NSArray<UIViewController *>)animated:同时为UINavgationController设置所有的UIViewController

    =====================================================

     

    二、UINavigationBar(受UINavigationController管理)

    1、UINavigationBar位于屏幕顶端的控件,通常只是作为多个UINavigationBar的容器,同样是以栈的 形式来管理多个UINavigationItem控件

    2、UINavigationBar常用方法和属性

    1)backgroundColor  设置导航栏的背景色,毛玻璃边效果

    2)barTintColor  设置纯色背景 3)barStyle  状态栏系统样式(很少使用,一般我们都会加上背景图片)

    4)setBackgroundImage: forBarMetrics: 

    7.0之前,导航的高度为44

        7.0之后,导航的高度为64

      Metrics 指在什么状态下的图片(横32,竖64)

    a)UIBarMetricsDefault 竖屏

    (以下两个方法使用之前可以先判断当前的版本号再决定使用哪个)

    通过该方法获取版本号:[[[UIDevice currentDevice] systemVersion] floatValue]

    b)UIBarMetricsCompact 横屏 iOS8.0之后的方法

    c)UIBarMetricsLandscapePhone iOS8.0之前的横屏方法

    5)   hidden属性,YES为隐藏导航栏,NO为显示

    =========================================================

     

    三、UINavigationItem

     

    1、UINavigationItem常用方法和属性

     

    标题相关

    1)title 设置导航标题

    2)titleTextAttributes  设置导航栏标题的文字大小(key:NSFontAttributeName)和颜色(key:NSForegroundColorAttributeName)

    3)titleView  设置标题的UIView(可以使用自定义的)

    按钮相关(UIBarButtonItem)主要有右按钮rightBarButtonItem、左按钮leftBarButtonItem,还有多个按钮

    rightBarButtonItems:(NSArray)、leftBarButtonItems:(NSArray)

    4)initWithBarButtonSystemItem: target action:  系统自带的样式

    5)initWithCustomView:  自定义item样式

    6)initWithImage: style: target: action: 以图片方式设置item样式

    7)initWithTitle: style: target: action: 以文字样式设置item

    8)tintColor 渲染item颜色

    9)弹簧效果

      这是系统的样式,得指定弹开的宽度:UIBarButtonSystemItemFixedSpace 

      width  设置弹开的宽度

         这是系统的样式,会自动弹开:UIBarButtonSystemItemFlexibleSpace 

    10)hidesBackButton 该属性设置是否显示左上角的back按钮,YES为隐藏

    ======================================================

     

    四、UIToolBar

     

    1、UIToolBar介绍

    1)UIToolBar存在于UINavigationController控制器中

         2)UIToolBar默认显示在UINavigationController的底部位置,且默认被隐藏

         3)当我们需要在屏幕的底部加一些按钮时我们就可以使用UIToolBar来设置他,不需要自己去创建UIView

         4)创建UIToolBar需要先创建一个UINavigationController控制器

     

    2、UIToolBar的常用方法和属性

        1)setBackgroundImage: forToolbarPosition: barmetrics:  

    设置toolBar的背景图片,UIToolBar的高度为44

        2)setToolBarHidden:  animated:  设置toolBar的隐藏和显示

     

     

     

     

     

     

     

     

  • 相关阅读:
    ARM的体系结构与编程系列博客——ARM体系版本
    eclipse快捷键
    ARM的体系结构与编程系列博客——ARM的历史与应用范围
    基于LINUX的多功能聊天室
    CC2530自动安全联网
    python3元组
    Python3 列表
    Python3 数字(Number)
    Python3 注释
    python3解释器
  • 原文地址:https://www.cnblogs.com/Mr-Lin/p/5107619.html
Copyright © 2011-2022 走看看