gpt4 book ai didi

iphone - 我怎样才能从上到下垂直移动我的 UIImage

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

我希望 UIImage 在屏幕上垂直向下移动,当它到达末尾时,它应该再次从顶部开始。我该怎么做???

请帮忙谢谢

最佳答案

假设您的 UIImage 位于 UIImageView 中,并且 ImageView 的大小为 320 x 480...

您的动画 block 可以在完成时调用方法。此方法重置 UIImageView 的位置,然后重新开始动画。

动画 block :

-(void)animate {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(myCallback:finished:context:)];

CGRect frame = yourImageView.frame;
frame.origin = CGPointMake(0, 480);
yourImageView.frame = frame;

[UIView commitAnimations];

}

回调:

(void)myCallback:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {

CGRect frame = yourImageView.frame;
frame.origin = CGPointMake(0, 0)
yourImageView.frame = frame;
[self animate];
}

关于iphone - 我怎样才能从上到下垂直移动我的 UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4441873/

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