需求:在有些项目中,为了显示更多的页面信息,需要在用户页面上拉时候,隐藏tabar那么怎么实现啦
实现:
1.监听tableView的滚动
通过监听到tableView的滚动
//开始滚动的位置
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
//时时位置
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
2.实现代码
#pragma mark - scrollView代理
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
lastContentOffset = scrollView.contentOffset.y;
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat offsetY = scrollView.contentOffset.y;
if (lastContentOffset < offsetY){
NSLog(@"向上滚动");
//隐藏tabar
[UIView animateWithDuration:1 animations:^{
self.tabBarController.tabBar.transform = CGAffineTransformMakeTranslation(0, 49);
}];
}else{
NSLog(@"向下滚动");
//显示[图片上传中...(示例动画.gif-8d959-1532596434570-0)]
tabar
[UIView animateWithDuration:1 animations:^{
self.tabBarController.tabBar.transform = CGAffineTransformIdentity;
}];
}
}
示例动画.gif
网友评论