gpt4 book ai didi

iphone - UIView 动画中的奇怪行为

转载 作者:行者123 更新时间:2023-11-28 20:21:41 29 4
gpt4 key购买 nike

我在 UIView 动画中遇到了一个奇怪的行为。我正在开发一个使用一些 UIView 动画的 iPad 应用程序。

所有动画的持续时间都设置为 0.5。最初启动应用程序时,所有动画都运行良好。但是在连续使用一段时间后没有动画发生,所有 UIView 变化都在快速发生,就像没有在动画中设置持续时间一样。

我不确定为什么会这样。有没有其他人遇到过这种问题?

以下是我正在使用的动画之一。像这样,我使用了很多动画,但一段时间后没有任何动画发生,但动画 block 中的所有代码都工作正常

[UIView animateWithDuration:0.5 animations:^{ 
[tempLabel setFont:titleFont.font];
[tempLabel setTransform: CGAffineTransformMakeRotation((-90 * M_PI / 180))];
tempLabel.frame = CGRectMake(2,0,23,30);
}];

最佳答案

来自UIView class reference , 框架属性:

Changes to this property can be animated. However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.

当您还设置了变换时,不要为框架设置动画。请改用边界和中心。

关于iphone - UIView 动画中的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15652992/

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