【发布时间】:2017-04-18 14:00:33
【问题描述】:
我想根据当前的触摸次数来更改 UIView 的颜色。我已经设法通过一次触摸来创建它:
class colorChangerViewClass: UIView {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
setColor(color: .blue)
print("touchesBegan")
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
setColor(color: .green)
print("touchesEnded")
}
func setColor(color: UIColor) {
self.backgroundColor = color
}
}
但我正在努力实现多点触控。我觉得我不明白这里的东西。
UIView 是否有一个属性来检查当前有多少手指在触摸它?
我可以检查每次新的 touchesBegan 或 touchesEnded 发生时。
【问题讨论】:
标签: ios iphone swift uiview uitouch