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 G开发者_Python百科uide me.
How about this?
UIImage *img = [button imageForState:UIControlStateNormal];
Swift 3.0 syntax
let image: UIImage = yourButton.image(for: .normal)!
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"];
精彩评论