开发者

How do I get an image from an UIButton?

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"];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜