简单实现Tabbar的隐藏显示动画 By H罗
简单实现Tabbar的隐藏显示动画
Hide Tabbar Controller with Animation
- (void)setTabBarVisible:(BOOL)visible animated:(BOOL)animated { // bail if the current state matches the desired state if ([self tabBarIsVisible] == visible) return; // get a frame calculation ready CGRect frame = self.tabBarController.tabBar.frame; CGFloat height = frame.size.height; CGFloat offsetY = (visible)? -height : height; // zero duration means no animation CGFloat duration = (animated)? 0.3 : 0.0; [UIView animateWithDuration:duration animations:^{ self.tabBarController.tabBar.frame = CGRectOffset(frame, 0, offsetY); }]; }
判断tabBar当前状态
// know the current state - (BOOL)tabBarIsVisible { return self.tabBarController.tabBar.frame.origin.y < CGRectGetMaxY(self.view.frame); }
//调用
- (void)buttonClick{ [self setTabBarVisible:![self tabBarIsVisible] animated:YES]; }
作者:SIBU iOS DEV
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.