當我點擊圖片時需要將UIButtons移動到視圖中,並且當我再次點擊同一圖片時需要將UIButton移出屏幕。當我點擊圖片時移動UIButtons
當我點擊一個UIImage時,4個UIButtons在屏幕內移動,下面的代碼沒有問題。
func imageTapped(img: AnyObject)
{UIView.animateWithDuration(0.5,
delay: 0,
options: [.CurveEaseInOut, .AllowUserInteraction],
animations: {
self.imageReceivedTrashCan.center = CGPoint(x: 30, y: 530)
self.imageReceivedRightArrow.center = CGPoint(x: 285, y: 530)
self.imageReceivedForward.center = CGPoint(x: 160, y: 530)
self.imageReceivedCross.center = CGPoint(x: 30, y: 30)
},
completion: { finished in
print("Objects moved!")
})
}
但是,我無法找到一種方法,我怎麼可以移動UIButtons回當我再次同一幅圖像上單擊原來的位置。感謝你的幫助。
您似乎總是按鈕(圖像)移動到?圖片。你需要檢查垃圾桶,箭頭等是否在圖像內部,如果是的話,將它們移出。放置一個條件代碼塊,將圖像移回。 – wottle