[英]How do I get an image from an UIButton?
我在我的應用程序中有自定義按鈕,我在其中設置了圖像。 我想從按鈕獲取圖像並存儲在UIImage變量中。 請指導我。
這個怎么樣?
UIImage *img = [button imageForState:UIControlStateNormal];
Swift 3.0語法
let image: UIImage = yourButton.image(for: .normal)!
UIImage *myNewImage = [UIButton imageForState:UIControlStateNormal];
雖然這不是很好的設計實踐。 我會這樣做:
UIImage *myNewImage = [UIImage imageNamed:@"name of image that is in your bundle"];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.