iOS Learning Uinavigationcontroller

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.