滑动隐藏tabBar
来源:互联网 发布:mac怎么删除应用 编辑:程序博客网 时间:2024/05/14 13:22
在需要滑动隐藏/显示的页面中:
@property(nonatomic,assign)CGFloat historyY;
#pragma mark Delegate
//设置滑动的判定范围
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
if (historyY+20<targetContentOffset->y)
{
[self setTabBarHidden:YES];
}
else if(historyY-20>targetContentOffset->y)
{
[self setTabBarHidden:NO];
}
historyY=targetContentOffset->y;
}
//隐藏显示tabbar
- (void)setTabBarHidden:(BOOL)hidden
{
UIView *tab = self.tabBarController.view;
CGRect tabRect=self.tabBarController.tabBar.frame;
if ([tab.subviews count] < 2) {
return;
}
UIView *view;
if ([[tab.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]]) {
view = [tab.subviews objectAtIndex:1];
} else {
view = [tab.subviews objectAtIndex:0];
}
if (hidden) {
view.frame = tab.bounds;
tabRect.origin.y=[[UIScreen mainScreen]bounds].size.height+self.tabBarController.tabBar.frame.size.height;
} else {
view.frame = CGRectMake(tab.bounds.origin.x, tab.bounds.origin.y, tab.bounds.size.width, tab.bounds.size.height);
tabRect.origin.y=[[UIScreen mainScreen] bounds].size.height-self.tabBarController.tabBar.frame.size.height;
}
[UIView animateWithDuration:0.5f animations:^{
self.tabBarController.tabBar.frame=tabRect;
}completion:^(BOOL finished) {
}];
}
- 滑动隐藏tabBar
- 滑动过程中隐藏tabBar
- iOS 滑动隐藏/显示tabbar
- 隐藏StatusBar/TabBar/导航滑动返回
- iOS tableView滑动隐藏/显示tabbar
- 滑动隐藏和显示tabBar和NavigationBar
- 隐藏tabbar
- 隐藏tabbar
- 隐藏tabbar
- 隐藏tabbar
- tabBar隐藏
- 隐藏tabBar
- 隐藏tabbar
- 隐藏TabBar
- 隐藏tabbar
- 隐藏tabBar
- 隐藏tabbar
- 隐藏TabBar
- Makefile 自动生成依赖
- 自定义View之--九宫格图形密码锁
- 前端页面引入文件后加如随机数
- ADO数据库编程
- Circular view path [...]: would dispatch back to the current handler
- 滑动隐藏tabBar
- 数据结构(最大子列和问题)
- VisualStudio2015--错误记录总结
- C#之流程控制语句
- SpringBoot实战_1 Spring项目搭建
- HTML-01 初识
- JavaScript神奇的魔法代码
- 文本属性1
- 基本日期与时间转换