我花了一天时间尝试更好地理解动画。下一个代码效果很好并隐藏了我的标签栏。问题是它会拉伸它附近的每个 UIButton。包括标签栏上的自定义按钮。如果它触及另一层图像,它将拉伸它。知道如何修复代码以避免这种情况吗?谢谢
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView animateWithDuration:0.3
delay:0.0f
options:UIViewAnimationCurveLinear
animations:^{
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]] || [view isKindOfClass:[UIImageView class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
}
completion:nil];
}
隐藏后: