Reputation: 7840
I have Custom Buttons in my application in which I have set images. I want to get image from button and stored in UIImage variable. Kindly Guide me.
Upvotes: 19
Views: 16953
Reputation: 3259
Swift 3.0 syntax
let image: UIImage = yourButton.image(for: .normal)!
Upvotes: 2
Reputation: 9126
UIImage *myNewImage = [UIButton imageForState:UIControlStateNormal];
Though this isn't very good design practice. I would do this:
UIImage *myNewImage = [UIImage imageNamed:@"name of image that is in your bundle"];
Upvotes: 0
Reputation: 104065
How about this?
UIImage *img = [button imageForState:UIControlStateNormal];
Upvotes: 61