iosuser-interfaceuibuttoninsetsimageedgeinsets

UIButton image on right title in center


I was searching through the post and trying to figure it out by myself but it is hardly working.

I want to use an UIButton with image and title.
UIButton spans across (almost) whole screen.
The image should be positioned on the right edge of the button.
The title should be centered in the whole button.

How can I do it with insets?


Solution

  • Thanks to the link provided I have used

    Control.ContentEdgeInsets = new UIEdgeInsets(0, -imageWidth, 0, 0);
    Control.ImageEdgeInsets = new UIEdgeInsets(0, controlWidth, 0, 0);