1

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?

Bryan
  • 14,756
  • 10
  • 70
  • 125
Dzior
  • 1,485
  • 1
  • 14
  • 30
  • you need to set `[button setImageEdgeInsets:UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 30.0f)];` Where UIEdgeInsets UIEdgeInsetsMake ( CGFloat top, CGFloat left, CGFloat bottom, CGFloat right ); – Nimit Parekh Apr 21 '15 at 10:32
  • Yeah I know about method, my question is, what values should I use? (I don't want to use magic numbers) – Dzior Apr 21 '15 at 10:41
  • 1
    refer this link may help you http://stackoverflow.com/questions/28340575/uibutton-different-alignment-for-title-and-image/28341513#28341513 – SGDev Apr 21 '15 at 10:42
  • Please share screen shot of expected output – Ashok Londhe Apr 21 '15 at 10:59

1 Answers1

11

Thanks to the link provided I have used

Control.ContentEdgeInsets = new UIEdgeInsets(0, -imageWidth, 0, 0);
Control.ImageEdgeInsets = new UIEdgeInsets(0, controlWidth, 0, 0);
Dzior
  • 1,485
  • 1
  • 14
  • 30