I want to set the image of a UIButton on a particular event. This is what I did:
btn.setImage(UIImage(named: "star"))
Objective-C
UIImage *img = [UIImage imageNamed:@"star.png"];
[btn setImage:img forState:UIControlStateNormal];
Swift 3
let img = UIImage(named: "star")
btn.setImage(img , forState: .normal)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With