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.
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.
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.
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.
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
How about this?
UIImage *img = [button imageForState:UIControlStateNormal];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With