我是新來的斯威夫特和工作中,我將我的綠色按鈕(顯示在圖片)的應用移動與手指到左側,當手指從按鈕中移除,然後按鈕移動到其之前的位置。還有四個不同的按鈕背景圖像,在從當前位置到左側按鈕的每次移動之後都會改變。但我無法理解,我是如何做到這一點的。請幫我完成我的任務。移動按鈕,返回到其第一位置,當觸摸結束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