To simulate the behavior of piano keys, I used the following UIControlEvents :
self.addTarget(self, action: "pressed", forControlEvents: [.touchDown]) self.addTarget(self, action: "released", forControlEvents: [.touchDragExit, .touchUpInside, .touchUpOutside, .touchCancel])
source share