Solo un aggiornamento alle risposte precedenti:
Se vuoi vedere i cambiamenti nell'evento click, cioè il colore del tuo UIVew shud cambia ogni volta che l'utente fa clic su UIView, allora apporta le modifiche come di seguito ...
class ClickableUIView: UIView {
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
if let touch = touches.first {
let currentPoint = touch.locationInView(self)
// do something with your currentPoint
}
self.backgroundColor = UIColor.magentaColor()//Color when UIView is clicked.
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
if let touch = touches.first {
let currentPoint = touch.locationInView(self)
// do something with your currentPoint
}
self.backgroundColor = UIColor.magentaColor()//Color when UIView is clicked.
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
if let touch = touches.first {
let currentPoint = touch.locationInView(self)
// do something with your currentPoint
}
self.backgroundColor = UIColor.whiteColor()//Color when UIView is not clicked.
}//class closes here
Inoltre, chiama questa classe da Storyboard e ViewController come:
@IBOutlet weak var panVerificationUIView:ClickableUIView!