zoukankan      html  css  js  c++  java
  • Iphone隐藏和显示TabBar的方法

    1.隐藏TabBar:

    1. - (void)hideTabBar {  
    2.     if (self.tabBarController.tabBar.hidden == YES) {  
    3.         return;  
    4.     }  
    5.     UIView *contentView;  
    6.     if ( [[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )  
    7.         contentView = [self.tabBarController.view.subviews objectAtIndex:1];  
    8.     else  
    9.         contentView = [self.tabBarController.view.subviews objectAtIndex:0];  
    10.     contentView.frame = CGRectMake(contentView.bounds.origin.x,  contentView.bounds.origin.y,  contentView.bounds.size.width, contentView.bounds.size.height + self.tabBarController.tabBar.frame.size.height);          
    11.     self.tabBarController.tabBar.hidden = YES;  
    12.       
    13. }  

    2.显示TabBar:
    1. - (void)showTabBar  
    2.   
    3. {  
    4.     if (self.tabBarController.tabBar.hidden == NO)  
    5.     {  
    6.         return;  
    7.     }  
    8.     UIView *contentView;  
    9.     if ([[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]])  
    10.           
    11.         contentView = [self.tabBarController.view.subviews objectAtIndex:1];  
    12.   
    13.     else  
    14.           
    15.         contentView = [self.tabBarController.view.subviews objectAtIndex:0];        
    16.     contentView.frame = CGRectMake(contentView.bounds.origin.x, contentView.bounds.origin.y,  contentView.bounds.size.width, contentView.bounds.size.height - self.tabBarController.tabBar.frame.size.height);  
    17.     self.tabBarController.tabBar.hidden = NO;  
    18.       
    19. }  

    3.如果定义了上面两个方法,在viewDidAppear:方法里面就可以调用了
    1. -(void)viewDidAppear:(BOOL)animated{  
    2.     //[self hideTabBar];  
    3.     [self showTabBar];  
    4. }  
  • 相关阅读:
    Chino 操作系统开发日志 (1)
    将Asp.Net Core和corefx移植到.Net 4.0
    C++编写操作系统(1):基于 EFI 的 Bootloader
    第二次作业:支付宝手机软件分析
    第一次作业:以人为鉴 可以明得失
    个人附加作业
    个人作业3---个人总结
    结对编程2---单元测试
    个人作业2---必应词典案例分析
    结对编程作业1
  • 原文地址:https://www.cnblogs.com/a7345678/p/2567225.html
Copyright © 2011-2022 走看看