IOS UITabBar-持续更新

1.系统方法  self.hidesBottomBarWhenPushed = YES;

  该方法存在一定缺陷,根据其名字可以发现,只有在push的时候才会生效,也就是说在UITabBarControllerUINavigationController结合使用的时候能用。

2.第二种方法比较通用,原理也很简单。

  修改 TabBar 的 subview 的 frame 就行了。其中,UITabBarControllersubview 共有两个,一个叫 UITabBar,就是底下的那个 Bar;另一个叫UITranstionview,就是 Bar 上面的视图。这两个 view 下面还有其他的subview,这就不用去管它了。UITabBar的 y 向下移49个单位,把UITranstionview 的 hight 加长 49 个单位。

复制代码
 1 - (void)hidesTabBar:(BOOL)hidden{
 2     
 3     
 4     [UIView beginAnimations:nil context:NULL];
 5     [UIView setAnimationDuration:0];
 6     
 7     for (UIView *view in self.tabBarController.view.subviews) {
 8         if ([view isKindOfClass:[UITabBar class]]) {
 9             if (hidden) {
10                 [view setFrame:CGRectMake(view.frame.origin.x, [UIScreen mainScreen].bounds.size.height, view.frame.size.width , view.frame.size.height)];
11                
12             }else{
13                 [view setFrame:CGRectMake(view.frame.origin.x, [UIScreen mainScreen].bounds.size.height - 49, view.frame.size.width, view.frame.size.height)];
14                 
15             }
16         }else{
17             if([view isKindOfClass:NSClassFromString(@"UITransitionView")]){
18                 if (hidden) {
19                     [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, [UIScreen mainScreen].bounds.size.height)];
20                     
21                 }else{
22                     [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, [UIScreen mainScreen].bounds.size.height - 49 )];
23                    
24                 }
25             }
26         }
27     }
28     [UIView commitAnimations];
29     
30 }
 
 
原创:http://blog.csdn.net/yongyinmg/article/details/39965465
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值