I am creating a custom button which (almost) works fine. It is supposed to change it's image when the button is pressed down, and the change back again when you let loose. The problem is that it takes one click before it starts working.
@IBOutlet weak var myButton: UIButton!
@IBAction func myButton(sender: UIButton) {
myButton.setImage(UIImage(named: "myImage.png")!, forState: .Normal)
myButton.setImage(UIImage(named: "myImagePressed.png")!, forState: .Highlighted)
myButton.setImage(UIImage(named: "myImagePressed.png")!, forState: .Selected)
}