IOS7 above to customize a Navigationcontroller and follow the system's side-slip return effect

Source: Internet
Author: User

The subclass of a navigationcontroller is required first, and some basic requirements for custom Nav are set in the Init method.

1-(Instancetype) Initwithrootviewcontroller: (Uiviewcontroller *) Rootviewcontroller2 {3     if(self =[Super Initwithrootviewcontroller:rootviewcontroller]) {4         //set the background color of the navigationbar and set it yourself as needed5Self.navigationBar.barTintColor =Redbuttoncolor;6         //setting Navigationbar is transparent, opaque, causes the available interface origin to move down (0,0) to the point below the lower left corner of the navigation bar7Self.navigationBar.translucent =NO;8         //set Navigationbar is not returned by default, yes9self.interactivePopGestureRecognizer.enabled =YES;Ten         //Create a color that makes it easy to set colors later OneUicolor * color =[Uicolor Whitecolor]; A         //sets the background color of the navigationbar element, excluding the title -Self.navigationBar.tintColor =color; -         //sets the font color for the title of the Navigationcontroller theNsdictionary * dict=[Nsdictionary dictionarywithobject:color forkey:nsforegroundcolorattributename]; -Self.navigationBar.titleTextAttributes =dict; -     } -      +     returnSelf ; -}

Because the navigation bar is self-defined, the default side-by-side return is invalidated, and the next proxy to follow the gesture in the Viewdidload

-(void) viewdidload{    //  Create weak Reference object    typeof (self) weakself = Self ;     if ([Self respondstoselector: @selector (Interactivepopgesturerecognizer)]) {        Self.interactivepopgesturerecognizer. delegate = weakself;    }}

OK, Finish.

IOS7 above to customize a Navigationcontroller and follow the system's side-slip return effect

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.