gpt4 book ai didi

ios - 链接 UIView 动画?

转载 作者:行者123 更新时间:2023-11-28 21:59:51 26 4
gpt4 key购买 nike

我正在尝试使图像从坐标 x=80 和 y=249 开始,然后移动到 x=284 和 y=99。然后从那里它会去 x=488 和 y=249。

这就是我得到的,但由于某种原因,图像从 x=284 和 y=99 开始,然后移动到 x=488 和 y=249。我需要帮助来解决这个问题。

    -(void)BallArchR{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 1.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
CGPoint center = [Ball center];
center.x = 284;
center.y = 99;
[Ball setCenter:center];
[UIView commitAnimations];
[self BallArchR2];
}

-(void)BallArchR2{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 1.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
CGPoint center = [Ball center];
center.x = 488;
center.y = 249;
[Ball setCenter:center];
[UIView commitAnimations];
}

最佳答案

因为您直接从 BallArchR 方法调用 BallArchR2 方法。但实际上,在 BallArchR2 方法被调用之前,BallArchR 方法的动画并不完整。因此,在第一个 BallArchR 方法动画完成后调用 BallArchR2 方法。所以你可以试试这个希望它对你有帮助:

-(void)BallArchR{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 1.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
CGPoint center = [Ball center];
center.x = 284;
center.y = 99;
[Ball setCenter:center];
[UIView commitAnimations];

dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1.55 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self BallArchR2];
});
}

-(void)BallArchR2{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 1.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
CGPoint center = [Ball center];
center.x = 488;
center.y = 249;
[Ball setCenter:center];
[UIView commitAnimations];
}

关于ios - 链接 UIView 动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25397208/

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