码迷,mamicode.com
首页 > 其他好文 > 详细

简单实现Tabbar的隐藏显示动画 By H罗

时间:2015-05-22 18:48:57      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:

简单实现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];
}

 

Stackoverflow

 

 

简单实现Tabbar的隐藏显示动画 By H罗

标签:

原文地址:http://www.cnblogs.com/sixindev/p/4522889.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!