Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You only need the background in a single image if you use the following technique.</p> <pre><code>UIImage *backgroundImage = [[UIImage imageNamed:@"MyImageTitle"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, leftInset, 0, rightInset)]; </code></pre> <p>where <code>leftInset</code> is the width of unstretchable content from the left side of the image and <code>rightInset</code> is the width of unstretchable content from the right side of the image.</p> <p>This will create an image that only stretches content inside the defined insets. This is the best way to solve this problem.</p> <p>Alternatively, if you cannot possibly combine your images then you can do it like this.</p> <pre><code>UIImage *leftImage = [UIImage imageNamed:@"edit_category_left_up"]; UIImage *middleImage = [UIImage imageNamed:@"edit_category_middle_up"]; UIImage *rightImage = [UIImage imageNamed:@"edit_category_right_up"]; UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, leftImage.size.width, btn.frame.size.height)]; [leftImageView setImage:leftImage]; UIImageView *middleImageView = [[UIImageView alloc] initWithFrame:CGRectMake(leftImageView.frame.size.width, 0, btn.frame.size.width - (leftImage.size.width + rightImage.size.width), btn.frame.size.height)]; [middleImageView setImage:middleImage]; UIImageView *rightImageView = [[UIImageView alloc] initWithFrame:CGRectMake(middleImageView.frame.origin.x + middleImageView.frame.size.width, 0, rightImage.size.width, btn.frame.size.height)]; [rightImageView setImage:rightImage]; [btn addSubview:leftImageView]; [btn addSubview:middleImageView]; [btn addSubview:rightImageView]; </code></pre> <p>You might need to play around with the layer the subviews are inserted at. To do that you can use one of these methods:</p> <p><code>[btn insertSubview:view aboveSubview:otherView];</code></p> <p><code>[btn insertSubview:view atIndex:someIndex];</code></p> <p><code>[btn insertSubview:view belowSubview:otherView];</code></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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    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