如何在 UIView 动画之前更新 UI

发布于 2024-10-03 17:28:21 字数 469 浏览 0 评论 0原文

我在程序中向 UIView 添加了一个动画。视图中有很多控件。我试图在动画之前隐藏一些控件,所以我将隐藏属性设置为YES。但它不起作用。在动画过程中它仍然在图层上可见。

这是一些代码:

button.hidden = YES;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
[UIView commitAnimations]

谁能告诉我如何在动画之前隐藏控件? 或者如何更新控制雕像(控制位置,可见等)

谢谢

I add an animation to UIView in my program. There are many controls in the view. I tried to hide some controls before animation, so I set hidden property to YES. But it didn't work.It still visible on the layer during the animation.

here is some code:

button.hidden = YES;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
[UIView commitAnimations]

Could any one tell me how to hide controls before animation?
Or how to update control statues(control position, visible, etc)

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

许久 2024-10-10 17:28:21

如果您尝试为视图设置动画,则设置其新值的语句(例如(button.hidden = YES))应位于动画块内,如下所示。

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
button.hidden = YES;
[UIView commitAnimations];

If you're trying to animate a view, the statement that sets its new value, like (button.hidden = YES), should be located INSIDE your animation block, like so.

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
button.hidden = YES;
[UIView commitAnimations];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文