我是新来的斯威夫特和工作中,我将我的绿色按钮(显示在图片)的应用移动与手指到左侧,当手指从按钮中移除,然后按钮移动到其之前的位置。还有四个不同的按钮背景图像,在从当前位置到左侧按钮的每次移动之后都会改变。但我无法理解,我是如何做到这一点的。请帮我完成我的任务。移动按钮,返回到其第一位置,当触摸结束IOS斯威夫特
这里是我的代码
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
location = ((touches.first)?.location(in: self.view))!
let position = view.convert(location, to: view)
print("Touches Began \(location)")
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
location = ((touches.first)?.location(in: self.view))!
let position = view.convert(location, to: view)
print("touches Moved: \(location)")
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
// dont know how i perform
}
我觉得这是更好地做一个GIF动画或绘制两个具有两个结束状态的图像。比每个人都明白你想要做什么。 – blyabtroi