我可以使用下面的代码移动单个UIView
,但我怎么移动多个UIView
的单独使用IBOutletCollection
和tag
值?如何拖动图像
class TeamSelection: UIViewController {
var location = CGPoint(x: 0, y: 0)
@IBOutlet weak var ViewTest: UIView! // move a single image
@IBOutlet var Player: [UIView]! // collection to enable different images with only one outlet
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
let touch: UITouch = touches.first! as UITouch
location = touch.location(in: self.view)
ViewTest.center = location
}
}
谢谢,我将如何使用@IBOutlet var Player:[UIView]!在移动图像的功能内 – Chet
@Chet - 你有插座的事实是无关紧要的。问题是你如何实例化这些视图。例如,如果在IB中,请确保将这些玩家视图的基类指定为上面显示的自定义类。但是,所有的'@ IBOutlet'东西是不变的 – Rob
我忘了子类分配给imagueView – Chet