ios - Hide only the Navigation Bar when scrolling like Instagram iOS8 -


in app trying hide uitableviewcontroller's navigation bar when scrolling. have tried using self.navigationcontroller.hidesbarsonswipe = yes; adds strange bottom blank space , hides background of uistatusbar. to, when scrolling down, hide navbar, , when scrolling little, make navbar re-appear. behavior im looking instagram's feed, hides navbar when scrolling.

could guide me how achieve simple code , not involve github project or external source of kind. customize performance needs. thanks.

register view controller uiscrollviewdelegate example.

- (void)scrollviewdidscroll:(uiscrollview *)scrollview; - (void)scrollviewdidenddecelerating:(uiscrollview *)scrollview; - (void)scrollviewdidenddragging:(uiscrollview *)scrollview willdecelerate (bool)decelerate; 

from within de uiscrollviewdelegate methods can new contentoffset , translate uinavigationbar or down accordingly.

setting alpha of subviews can done based on threshold values , factors can set , compute.

hope helps!

or can use this

@property (strong, nonatomic) nsarray *navbaritems;      -(void)scrollviewdidscrolltotop:(uiscrollview *)scrollview {     if([[[uidevice currentdevice] systemversion] floatvalue] < 7.0f){         return;     }      cgrect frame = self.navigationcontroller.navigationbar.frame;     frame.origin.y = 20;      if(self.navbaritems.count > 0){         [self.navigationcontroller.navigationbar setitems:self.navbaritems];     }      [self.navigationcontroller.navigationbar setframe:frame]; }  -(void)scrollviewdidscroll:(uiscrollview *)scrollview {     if([[[uidevice currentdevice] systemversion] floatvalue] < 7.0f){         return;     }      cgrect frame = self.navigationcontroller.navigationbar.frame;     cgfloat size = frame.size.height - 21;      if([scrollview.pangesturerecognizer translationinview:self.view].y < 0)     {         frame.origin.y = -size;          if(self.navigationcontroller.navigationbar.items.count > 0){             self.navbaritems = [self.navigationcontroller.navigationbar.items copy];             [self.navigationcontroller.navigationbar setitems:nil];         }     }     else if([scrollview.pangesturerecognizer translationinview:self.view].y > 0)     {         frame.origin.y = 20;          if(self.navbaritems.count > 0){             [self.navigationcontroller.navigationbar setitems:self.navbaritems];         }     }      [uiview beginanimations:@"togglenavbar" context:nil];     [uiview setanimationduration:0.2];     [self.navigationcontroller.navigationbar setframe:frame];     [uiview commitanimations]; } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -