gpt4 book ai didi

iphone - iOS 中的基本 Sprite/UIImage 运动?

转载 作者:行者123 更新时间:2023-11-28 22:52:39 26 4
gpt4 key购买 nike

我想将图像从屏幕的一侧移动到另一侧。

我有两个 UIImageView,ball1 和 ball2。左边一个,右边一个。设备处于横向模式。当用户单击一个按钮时,我希望他们换边,就像补间动画一样。我试过使用 CGPoint,但我无法弄明白。

最佳答案

CGPoint firstCenter = ball1.center;
CGPoint secondCenter = ball2.center;
[UIView animateWithDuration:1.0 animations:^{
ball1.center = secondCenter;
ball2.center = firstCenter;
}];

关于iphone - iOS 中的基本 Sprite/UIImage 运动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11554444/

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