A9628298AF2F97B5E073C680D9D5DC85 Apps King Technologies: Hide And Show TabBar in iOS

Tuesday 25 February 2014

Hide And Show TabBar in iOS


Hide TabBar in iOS:

- (void) showTabBar:(UITabBarController *) tabbarcontroller
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    float fHeight;
    ifUIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
    {
        fHeight = screenRect.size.width - 49.0;
    }
    else
    {
      fHeight = screenRect.size.height-49.0;
    }
    
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    for(UIView *view in tabbarcontroller.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            float x1 = view.frame.origin.x;
            float y1 = fHeight;
            float x11 = view.frame.size.width;
            float y11 = view.frame.size.height;
            if(flag)
            {
                x1 = 30;
                flag=0;
                
            }
            else
            {
                x1 = 0;
                flag = 1;
            }

            [view setFrame:CGRectMake(x1, fHeight, view.frame.size.width, view.frame.size.height)];
            NSLog(@"x1 %f ,x11 %f, y1 %f,y11 %f",x1,y1,x11,y11);
        }
        else
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
        }
    }
    [UIView commitAnimations];
}



- (void) hideTabBar:(UITabBarController *) tabbarcontroller
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    float fHeight = screenRect.size.height;
    ifUIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
    {
        fHeight = screenRect.size.width;
    }
    
    for(UIView *view in tabbarcontroller.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            float x1 = view.frame.origin.x;
            float y1 = fHeight+49;
            float x11 = view.frame.size.width;
            float y11 = view.frame.size.height;
            if(flag)
            {
                y11 = 0;//view.frame.size.height-49;
                flag = 0;
            }
            else
            {
                flag = 1;
            }
            [view setFrame:CGRectMake(x1,y1,y1,y11)];
            NSLog(@"x1 %f ,x11 %f, y1 %f,y11 %f",x1,y1,x11,y11);
        }
        else
        {
           [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y , view.frame.size.width,fHeight)];
            
            view.backgroundColor = [UIColor blackColor];
          
        }
    }
    [UIView commitAnimations];
    

}




//*******************************************************************************


- (void) showTabBar:(UITabBarController *) tabbarcontroller
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    
    
    float fHeight;
    ifUIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
    {
        fHeight = screenRect.size.width - 49.0;
    }
    else
    {
      fHeight = screenRect.size.height-49.0;
    }
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    for(UIView *view in tabbarcontroller.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
        }
        else
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
        }
    }
    [UIView commitAnimations];
}



- (void) hideTabBar:(UITabBarController *) tabbarcontroller
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    float fHeight = screenRect.size.height;
    ifUIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
    {
        fHeight = screenRect.size.width;
    }
    
    for(UIView *view in tabbarcontroller.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x, fHeight+50, view.frame.size.width, view.frame.size.height-49)];
        }
        else
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y+50, view.frame.size.width,fHeight)];
            
            view.backgroundColor = [UIColor blackColor];
          
        }
    }
    [UIView commitAnimations];
    
}



1 comment: