gpt4 book ai didi

iphone - UIView取消动画

转载 作者:行者123 更新时间:2023-12-03 21:22:08 32 4
gpt4 key购买 nike

我目前有一个从屏幕的一个部分到另一部分的动画 View 。我希望每当按下“暂停”按钮时动画就会暂停。这意味着当我“暂停”动画时,动画需要保持在原来的位置(帧位置)。我尝试了一些方法,但没有任何结果能达到我想要的结果。下面是我当前代码的粗略版本。

-(IBAction)startScroll
{
NSLog(@"Start scroll");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:30];

//set new frame for view

[UIView commitAnimations];
}

以及一种停止动画的方法

-(IBAction)pauseScroll
{
NSLog(@"Pause Scroll");

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:0.1];

//Pause animation in it's current location

[UIView commitAnimations];

}

最佳答案

最终使用计时器并每隔几秒更新一次 contentOffset。希望有一种更好的方法来获取当前坐标,即使在动画过程中也是如此。 presentationLayer 的东西没有产生成功的结果。

关于iphone - UIView取消动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3692540/

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