When I try using this solution to update an UIButton image (Xcode 7 beta 1), it gives me this error
Cannot invoke 'setImage' with an argument list of type '(UIImage?, forState: nil)'
Here's the code:
if counter % 2 == 0{
playButton.setImage(UIImage(named: "pause"), forState: nil)
}
else if counter % 2 == 1 {
playButton.setImage(UIImage(named: "play"), forState: nil)
}
How can I fix this?
The
forState
argument cannot benil
- It has to be aUIControlState
.In your case, you should use
UIControlState.Normal