gpt4 book ai didi

objective-c - UIView:一个动画有多个变化

转载 作者:行者123 更新时间:2023-11-29 04:53:52 26 4
gpt4 key购买 nike

我需要在 UIView 上制作同步动画。我想同时改变大小和位置。我尝试这段代码:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationBeginsFromCurrentState:NO];

[openingElement setFrame:elementFrame];

[UIView commitAnimations];

这段代码有效,但 UIView 动画分两步(移动和调整大小后),我想一起做。是否可以制作一个动画进行多次更改?

最佳答案

可以在一个动画中进行多项更改。在 UIView 上,您可以同时对 alpha、边界、框架、中心、变换和背景颜色进行动画更改。

如果您在框架属性上遇到动画问题,请尝试对中心和边界进行动画处理。

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationBeginsFromCurrentState:NO];

[openingElement setBounds:newBounds];
[openingElement setCenter:newCenter];

[UIView commitAnimations];

关于objective-c - UIView:一个动画有多个变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8356932/

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