Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A quick sample :</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *img = [UIImage imageNamed:@"Arrow.png"]; [button setTitle:@"A Button" forState:UIControlStateNormal]; [button setImage:img forState:UIControlStateNormal]; [button sizeToFit]; CGRect imageRect = [button imageRectForContentRect:button.bounds]; CGRect titleRect = [button titleRectForContentRect:button.bounds]; UIEdgeInsets imageInset = UIEdgeInsetsZero; UIEdgeInsets titleInset = UIEdgeInsetsZero; titleInset.left = -2 * imageRect.size.width; imageInset.left = titleRect.size.width; button.titleEdgeInsets = titleInset; button.imageEdgeInsets = imageInset; [self.view addSubview:button]; CGFloat prevHeight = button.frame.size.height; UIButton *anotherButton = [UIButton buttonWithType:UIButtonTypeCustom]; [anotherButton setTitle:@"Another Button" forState:UIControlStateNormal]; [anotherButton setImage:img forState:UIControlStateNormal]; [anotherButton sizeToFit]; imageRect = [anotherButton imageRectForContentRect:anotherButton.bounds]; titleRect = [anotherButton titleRectForContentRect:anotherButton.bounds]; imageInset = UIEdgeInsetsZero; titleInset = UIEdgeInsetsZero; titleInset.left = -2 * imageRect.size.width; imageInset.left = titleRect.size.width; anotherButton.titleEdgeInsets = titleInset; anotherButton.imageEdgeInsets = imageInset; CGRect frame = anotherButton.frame; frame.origin.y += prevHeight + 4; [anotherButton setFrame:frame]; [self.view addSubview:anotherButton]; } </code></pre> <p><img src="https://i.stack.imgur.com/RB9dM.png" alt="Result for 2 buttons create like this"></p> <p>You just need to adjust buttons size and insets, if you want to add space between title and image.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload