ios-hidden Navigationbar "navigation bar seamless and sleek hidden"

Source: Internet
Author: User

1.ViewController

. m

- (void) viewdidload {[Super viewdidload]; Self.title=@"Hide Navigation bar"; UIButton*button =[UIButton Buttonwithtype:uibuttontypecustom]; Button.backgroundcolor=[Uicolor Lightgraycolor]; Button.frame= CGRectMake (Ten, -, -, -);    [Button addtarget:self action: @selector (ButtonClick) forcontrolevents:uicontroleventtouchupinside];            [Self.view Addsubview:button]; Self.navigationcontroller.Delegate=Self ;}- (void) buttonclick{///Jump to Kkviewcontroller[Self Performseguewithidentifier:@"Pusht"Sender:nil];}

Head Agent

@interface Viewcontroller () <UINavigationControllerDelegate>

Proxy method

-(void) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller Willshowviewcontroller: ( Uiviewcontroller *) Viewcontroller animated: (BOOL) animated {        [Self.navigationcontroller Setnavigationbarhidden: [self hiddenbarvc:viewcontroller] animated:animated];} -(BOOL) HIDDENBARVC: (Uiviewcontroller *) viewcontroller {        = NO;         if class ]]) {        = YES;    }         return Needhidenaivgaionbar;}
2.KKViewController (target Viewcontroller)

Create a new Kkviewcontroller

. h

ID popdelegate;

. m

- (void) viewdidload {[Super viewdidload]; Self.title=@"a second page"; [Self popset];}- (void) popset{_popdelegate= Self.navigationController.interactivePopGestureRecognizer.Delegate; SEL Action= Nsselectorfromstring (@"handlenavigationtransition:"); Uipangesturerecognizer*poppangesture =[[Uipangesturerecognizer alloc] initWithTarget:self.popDelegate action:action]; Poppangesture.maximumnumberoftouches=1; Poppangesture.Delegate=Self ; [Self.view addgesturerecognizer:poppangesture];}

Head Agent

@interface Kkviewcontroller () <UIGestureRecognizerDelegate>

Gesture Proxy method

-(BOOL) Gesturerecognizershouldbegin: (Uipangesturerecognizer *) gesturerecognizer{///"Here are two ways to write a"///Full Screen DragCgpoint Tragpoint =[Gesturerecognizer TranslationInView:gestureRecognizer.view]; if(Tragpoint.x <=0){        returnNO; }    Else{        if(Self.navigationController.viewControllers.count <=1){            returnNO; }        Else{            returnYES; }    }        //    ///local Allow drag//cgpoint tragpoint = [Gesturerecognizer LocationInView:gestureRecognizer.view];//NSLog (@ "x=%f;y=%f", tragpoint.x,tragpoint.y);//if (Tragpoint.x >) {///Drag the range//return NO;//    }//else{//if (self.navigationController.viewControllers.count <= 1) {//return NO;//        }//else{//return YES;//        }//    }}

ios-hidden Navigationbar "navigation bar seamless and sleek hidden"

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.