Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 Guide me.

like image 554
Siddiqui Avatar asked Jan 28 '11 10:01

Siddiqui


People also ask

What is the default position of a button image?

The default position of a button image will be on the leading edge of a button. The default position of a button image will be on the leading edge of a button. Sometimes, we might want to position the image on the trailing side, which is what we will learn in this article. You can easily support sarunw.com by checking out this sponsor.

How to flip an image on a button in iOS?

1 configuration.imagePlacement = .trailing position our image to the trailing edge of a button (right side in left-to-right languages and left side in right-to-left languages). This mean iOS do the flipping for us without a need for us to manually checking UIApplication.shared.userInterfaceLayoutDirection.

Does the UIKit read from right to left?

Some language reads from right to left. In iOS apps, UIKit controls appear mirrored in right-to-left languages. Here is the Apple Map interface in left-to-right and right-to-left languages. The Apple Map interface in left-to-right and right-to-left langauges. semanticContentAttribute is a property that allows us to control this flipping behavior.

How to set image and title in uicontrolstatenormal?

If you want to set both (your image and title) use the following code: btnImage = [UIImage imageNamed:@"image.png"]; [btnTwo setBackgroundImage:btnImage forState:UIControlStateNormal]; [btnTwo setTitle:@"Title" forState:UIControlStateNormal]; Share Improve this answer


1 Answers

How about this?

UIImage *img = [button imageForState:UIControlStateNormal];
like image 186
zoul Avatar answered Oct 10 '22 20:10

zoul