The following properties are all iOS7 after
Set the navigation bar style
Self.navigationController.navigationBar.barStyle = uibarstyleblacktranslucent;
Set the navigation bar background color
Self.navigationController.navigationBar.backgroundColor = [Uicolor Redcolor];
When setting the navigation bar background color, the navigation bar style cannot be uibarstyledefault.
Set the navigation bar background picture
[Self.navigationController.navigationBar setbackgroundimage:[uiimage imagenamed:@ "NAVBG"] forbarmetrics: Uibarmetricsdefault];
Uibarmetricsdefault is the iphone mode (vertical screen is called portrait mode, horizontal screen is called landscape mode), after setting the background image, the background color will be obscured. The image size must be 44. If it is too narrow it will be tiled and exceeded by the Convention. However, you can set another property of the navigation bar to crop. If you want the navigation bar to fill the status bar, the height set to 64,clipstobounds must be no.
Self.navigationController.navigationBar.clipsToBounds = YES;
Set the navigation bar to hide
Self.navigationController.navigationBarHidden = YES;
After iOS7, the view controller's start point is from the top of the screen, including the status bar. Therefore, you need to set aside 20 pixels for the layout.
Uinavigationitem detailed
Common Properties and methods:
@property (nonatomic, copy) NSString *title; Set the title, shown in the middle of the navigation bar @property (nonatomic, retain) UIView *titleview; Sets the title view, displayed in the middle of the navigation bar @property (nonatomic, retain) Uibarbuttonitem *leftbarbuttonitem; Left button @property (nonatomic, retain) Uibarbuttonitem *rightbarbuttonitem; Right button-(void) Setleftbarbuttonitem: (uibarbuttonitem*) Item animated: (BOOL) animated;-(void) Setrightbarbuttonitem: ( uibarbuttonitem*) Item Animated: (BOOL) animated;-(void) Setleftbarbuttonitems: (Nsarray *) Items animated: (BOOL) Animated; Sets a set of buttons on the left-(void) Setrightbarbuttonitems: (Nsarray *) Items animated: (BOOL) animated; Set a group of buttons to the right
Initialization method of Uibarbuttonitem
-(ID) Initwithimage: (uiimage*) Image style: (Uibarbuttonitemstyle) style target: (ID) Target action: (SEL) action;-(ID) Initwithtitle: (nsstring*) Title style: (Uibarbuttonitemstyle) style target: (ID) Target action: (SEL) action;-(ID) Initwithbarbuttonsystemitem: (uibarbuttonsystemitem*) Systemitem target: (ID) Target action: (SEL) action;-(ID) Initwithcustomview: (UIView *) CustomView;
When Uibarbuttonitemstyle is Uibarbuttonitemstyleplain style, the button color changes with the navigation bar color, and the button color is always blue when uibarbuttonitemstyledone style.
iOS Learning Uinavigationcontroller