#import <UIKit/UIKit.h>
//继承UITabBarController类,实现UITabBar的收缩
@interface UITabBarController (ShowHideBar)
- (void)hideTabBar;
- (void)showTabBar;
@end
#import "UITabBarController+ShowHideBar.h"
#import "Definition.h"
@implementation UITabBarController (ShowHideBar)
- (void)hideTabBar
{
for(UIView *view in self.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[view setFrame:CGRectMake(view.frame.origin.x, ScreenHeight, view.frame.size.width,
view.frame.size.height)];
[UIView commitAnimations];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,
view.frame.size.width, ScreenHeight)];
}
}
}
- (void)showTabBar
{
for(UIView *view in self.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[view setFrame:CGRectMake(view.frame.origin.x, ScreenHeight-49, view.frame.size.width,
view.frame.size.height)];
[UIView commitAnimations];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,
view.frame.size.width, ScreenHeight-49)];
}
}
}
@end