gpt4 book ai didi

ios - 在UITouchView中更改位置

转载 作者:行者123 更新时间:2023-12-01 17:01:22 26 4
gpt4 key购买 nike

我正在使用下面的代码在屏幕上拖动图像。我想更改的一件事是图像的位置。现在,位置会更改为每次触摸,因此每次我尝试移动它时,它都会转换为我的手指。我如何使其相对于手指移动?例如如果图像在屏幕中间,并且我将手指放在屏幕的右下角,则图像不会平移到我的手指上。希望有道理。提前致谢。

// get touch event
UITouch *touch = [[event allTouches] anyObject];

// get the touch location
CGPoint touchLocation = [touch locationInView:touch.view];

// move the image view
image.center = touchLocation;

最佳答案

关于ios - 在UITouchView中更改位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6594646/

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