屏幕向下滚动时导航栏动画特效

1

标题左右滚动和页面左右轮播的效果请参考:http://www.jianshu.com/p/b45655e23a42

标题向上滚动到屏幕之外的效果是使用代理方法完成的,具体如下:

@protocol ODHideNavBarDelegate <NSObject>

– (void)hideNavBar:(BOOL)needHide;

@end

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

    if (self.tableView.contentOffset.y > 100) {

        [self.delegate hideNavBar:YES];

    }else{

        [self.delegate hideNavBar:NO];

    }

}

– (void)hideNavBar:(BOOL)needHide{

    if (needHide == YES) {

        [UIView animateWithDuration:0.5 animations:^{

            self.titleLabel.y = –50;

            self.leaveBtn.y = –50;

            [self setUpContentViewFrame:^(UIView *contentView) {

                contentView.frame = CGRectMake(0,20, kWidthOfScreen, kHeightOfScreen);

            }];

        }];

    }

    

    if (needHide == NO) {

        [UIView animateWithDuration:0.5 animations:^{

            self.titleLabel.y = 20;

            self.leaveBtn.y = 20;

            [self setUpContentViewFrame:^(UIView *contentView) {

                contentView.frame = CGRectMake(0,64, kWidthOfScreen, kHeightOfScreen);

            }];

        }];

    }

}

发表评论