Six tips on the navigation bar and six tips on the navigation bar

Source: Internet
Author: User

Six tips on the navigation bar and six tips on the navigation bar

UINavigationBarAndUINavigationItemIs a common control in iOS development. Today I will introduce you to the six tips on the navigation bar.

1. Set the navigation bar title
Self. title = @ "iOS development: iOSDevTip ";
2. Set the navigation bar style

Setting method:

[self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];

UIBarStyleStyle:

typedef NS_ENUM(NSInteger, UIBarStyle) {    UIBarStyleDefault          = 0,    UIBarStyleBlack            = 1,    UIBarStyleBlackOpaque      = 1, // Deprecated. Use UIBarStyleBlack    UIBarStyleBlackTranslucent = 2, // Deprecated. Use UIBarStyleBlack and set the translucent property to YES};

UIBarStyleDefaultIs the default style,UIBarStyleBlackIt is black and opaque.UIBarStyleBlackOpaqueAndUIBarStyleBlackTranslucentThe two are obsolete.

To set the transparent navigation bar, add the following code:

self.navigationController.navigationBar.translucent = YES;
3. Modify the return button title
self.navigationItem.title = @"test";
4. Hide the title of the return button

The stupid method is:

self.navigationItem.title = @"";

You can also set it as follows:

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
5. Set leftBarButtonItem
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStylePlain target:self action:@selector(back:)];- (void)back:(id)sender{    [self.navigationController popViewControllerAnimated:YES];}
6. What should I do if the returned gesture is invalid when I slide left?

If you setleftBarButtonItemAfter that, the left slide returns the gesture to become invalid. SetUIGestureRecognizerDelegateProxy:

self.navigationController.interactivePopGestureRecognizer.delegate = self;

The above are six tips on the navigation bar. For more iOS development-related technologies, please pay attention to my public account iOS development:IOSDevTip

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.