Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is no straight-forward way to do this as far as I know. Here is one way to do it:</p> <p>Instead of one ImageView, create 3 UIImageView with equal width and height(1/3rd of original image). Upper and lower ImageView will stick to the top and bottom edge respectively, middle ImageView will have flexible bottom and top margin. You need to set the contentMode property of middle ImageView to <code>UIViewContentModeScaleAspectFit</code>(or <code>UIViewContentModeCenter</code> based on how you want to handle rotation) and the other ones to <code>UIViewContentModeScaleToFill</code>. You can set all these property from IB.</p> <p>Now you need to to set the image source of each one from code. In the <code>viewDidLoad</code> method slice the UIImage into 3 parts using the solutions from this <a href="https://stackoverflow.com/questions/6014953/how-to-split-an-image-in-to-multiple-parts">post</a> or using the following code snippet:</p> <pre><code>-(NSMutableArray *)getImagesFromImage:(UIImage *)image withRow:(NSInteger)rows withColumn:(NSInteger)columns { NSMutableArray *images = [NSMutableArray array]; CGSize imageSize = image.size; CGFloat xPos = 0.0, yPos = 0.0; CGFloat width = imageSize.width/rows; CGFloat height = imageSize.height/columns; for (int y = 0; y &lt; columns; y++) { xPos = 0.0; for (int x = 0; x &lt; rows; x++) { CGRect rect = CGRectMake(xPos, yPos, width, height); CGImageRef cImage = CGImageCreateWithImageInRect([image CGImage], rect); UIImage *dImage = [[UIImage alloc] initWithCGImage:cImage]; [images addObject:dImage]; xPos += width; } yPos += height; } return images; } </code></pre> <p>You may need to tweak a few things, but hopefully you get the idea.</p> <p>If you have the option, you can pre-split the image into 3 parts using photoshop/gimp and place them into the bundle. In that case you don't need to do image splitting in the code and everything can be done from IB.</p> <p>Hope this helps :)</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. 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