- (void) hideTabBar:(BOOL) hidden{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0];
UIView *window = [UIApplication sharedApplication].keyWindow;
for(UIView *view in self.tabBarController.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
if (hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, window.height, view.frame.size.width, view.frame.size.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, window.height-49, view.frame.size.width, view.frame.size.height)];
}
}
else
{
if (hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, window.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, window.height-49)];
}
}
}
[UIView commitAnimations];
}
本文介绍了一个自定义方法用于在iOS应用中隐藏或显示UITabBar,并通过UIView动画实现这一过程,确保UI平滑过渡。代码示例展示了如何调整TabBar的位置以达到隐藏效果。
1124

被折叠的 条评论
为什么被折叠?



