UINavigationController, uinavigationbar
Knowledge point:
1) UINavigationController
2) UINavigationBar
3) UINavigationItem
4) UIToolBar
========================================================== ====================
I. UINavigationController
1. Introduction to UINavigationController
1) UINavigationController is a navigation controller that uses stacks to control which controller is currently displayed on the screen.
2) It can change the Controller hierarchy through push and pop.
3) the return button is automatically provided to return to the last pushed controller without additional programming.
4) UINavigationController provides an animation for controller switching.
5) UINavgationController manages multiple uiviewcontrollers through stacks (multiple interfaces)
6) You can manage the navigation buttons of the current navigationBar.
7) UINavgationController automatically adds a UINavigationBar for each UIViewController that accepts its management
8) includes four parts: Ingress. UINavigationController
Forbidden. UIViewController
Forbidden. UINavigationBar
Forbidden. UINavigationItem
2. Navigation controller redirection
1) pushViewController: animated: Jump, switch to the next View Controller (pressure stack)
2) popViewControllerAnimated: returns the previous layer (Out stack)
3) popToRootViewControllerAnimated: returns the root View Controller (root View Controller)
4) popToViewController: animated: Return to the specified layer
5) setViewControllers :( NSArray <UIViewController *>) animated: sets all uiviewcontrollers for UINavgationController.
========================================================== ==================
Ii. UINavigationBar (managed by UINavigationController)
1. The UINavigationBar is a control located at the top of the screen. It is usually used as a container for multiple UINavigationBar and is also used as a stack to manage multiple UINavigationItem controls.
2. Common UINavigationBar methods and attributes
1) backgroundColor: Set the background color and edges of the navigation bar.
2) barTintColor set solid color background 3) barStyle status bar system style (rarely used, we usually add background images)
4) setBackgroundImage: forBarMetrics:
Before 7.0, the navigation height is 44
After 7.0, the navigation height is 64
Metrics indicates the status of the image (horizontal 32, vertical 64)
A) UIBarMetricsDefault portrait Screen
(Before using the following two methods, you can determine the current version number before deciding which one to use)
Use this method to obtain the version number: [[[UIDevice currentDevice] systemVersion] floatValue]
B) UIBarMetricsCompact method after iOS8.0
C) Method of Landscape Display before UIBarMetricsLandscapePhone iOS8.0
5) hidden attribute. YES indicates the hidden navigation bar, and NO indicates the display.
========================================================== ========================
Iii. UINavigationItem
1. Common UINavigationItem methods and attributes
Title-related
1) title: Set the navigation title
2) titleTextAttributes: Set the text size (key: NSFontAttributeName) and color (key: NSForegroundColorAttributeName) of the navigation bar title)
3) titleView: Set the title's UIView (which can be customized)
Buttons (UIBarButtonItem) include the right button rightBarButtonItem, the left button leftBarButtonItem, and multiple buttons.
RightBarButtonItems :( NSArray), leftBarButtonItems :( NSArray)
4) initWithBarButtonSystemItem: target action: the style that comes with the system.
5) initWithCustomView: Custom item Style
6) initWithImage: style: target: action: Set the item style as an image
7) initWithTitle: style: target: action: Set item in text style
8) tintColor rendering item color
9) Spring Effect
This is the system style. You must specify the bounce width: UIBarButtonSystemItemFixedSpace.
Width: Set the bounce width.
This is the system style and will automatically pop up: UIBarButtonSystemItemFlexibleSpace
10) hidesBackButton whether to display the back button in the upper left corner of the Property setting. YES indicates that the back button is hidden.
========================================================== ====================
Iv. UIToolBar
1. UIToolBar Introduction
1) UIToolBar exists in the UINavigationController.
2) UIToolBar is displayed at the bottom of UINavigationController by default and hidden by default.
3) when we need to add some buttons at the bottom of the screen, we can use UIToolBar to set the buttons and do not need to create the UIView by ourselves.
4) To create a UIToolBar, you must first create a UINavigationController.
2. Common UIToolBar methods and attributes
1) setBackgroundImage: forToolbarPosition: barmetrics:
Set the background image of the toolBar. The height of UIToolBar is 44.
2) setToolBarHidden: animated: sets hidden and displayed toolBar.