美文网首页导航
iOS 实现ScrollView 上滑隐藏Navigationb

iOS 实现ScrollView 上滑隐藏Navigationb

作者: husky_duang | 来源:发表于2016-03-19 18:00 被阅读679次

    1》//滑动隐藏导航栏,简书效果

    -(void)scrollViewDidScroll:(UIScrollView *)scrollView{

    CGPoint translation = [scrollView.panGestureRecognizer translationInView:scrollView.superview];

    [self.navigationController setNavigationBarHidden:translation.y<0 animated:YES];

    NSLog(@"ContentOffset  x is  %f,yis %f",translation.x,translation.y);

    }

    《2》//滑动隐藏导航栏, 结束时两个方向有速度,才执行

    -(void)scrollViewDidScroll:(UIScrollView *)scrollView{

    CGPoint translation = [scrollView.panGestureRecognizer translationInView:scrollView.superview];

    [self.navigationController setNavigationBarHidden:translation.y<0 animated:YES];

    NSLog(@"ContentOffset  x is  %f,yis %f",translation.x,translation.y);

    }

    相关文章

      网友评论

        本文标题:iOS 实现ScrollView 上滑隐藏Navigationb

        本文链接:https://www.haomeiwen.com/subject/mhvhlttx.html