gpt4 book ai didi

objective-c - 动画导致图像拉伸(stretch)

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:46:16 24 4
gpt4 key购买 nike

我花了一天时间尝试更好地理解动画。下一个代码效果很好,隐藏了我的标签栏。问题是它会拉伸(stretch)靠近它的每个 UIButton。包括标签栏上的自定义按钮。如果它接触到另一层图像,它将拉伸(stretch)它。知道如何修复代码以避免这种情况吗?谢谢

 - (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];
}

enter image description here

隐藏后:

enter image description here

最佳答案

它是一个 UIButton 而不是 UIImageView。从屏幕截图中可以明显看出,它是此按钮的其他部分。

所以你需要修改你的if条件为,

if([view isKindOfClass:[UIButton class]] || [view isKindOfClass:[UITabBar class]] || [view isKindOfClass:[UIImageView class]])

然后设置框架。同样,也更改您的显示方法。

关于objective-c - 动画导致图像拉伸(stretch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14033373/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com