【发布时间】:2017-08-03 02:03:56
【问题描述】:
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
let touchesSet = touches as NSSet
let touch = touchesSet.anyObject() as? UITouch
let location = touch?.location(in: self.view)
if touch!.view == bee1 {
bee1?.center = location!
} else if touch!.view == bee2 {
bee2?.center = location!
}
}
我需要使用 Swift 为 iOS 编写这个游戏;但我不知道如何使用 Swift 对图像应用触摸。到目前为止,我的尝试都失败了; touch!.view != 图片
【问题讨论】:
-
使用手势或使用按钮并将图像应用到该按钮
-
尝试将“用户交互启用”添加到您的蜜蜂图像。
-
你到底想达到什么目的?