Create border around UIImageView using 8 images

I have 8 images I took, 4 images for each of the corners and 4 images for each side UIImageView

. Now, like on Earth, I make them "bypassing" view

, so they form a nice, stretchable border, something like this (the white line is the border I'm trying to implement): enter image description here

Any ideas on how to implement a border view

based on 8 preset images?

EDIT: I don't want to draw the border, I want to use 8 images!

+3


source to share


1 answer


This is not really what you are asking for, but it is the solution that is closest to what you are trying to do.

You have to take 8 images and combine them into one single image and then make a resizable image out of it using resizableImageWithCapInsets:resizingMode:

.

The first arguments allow you to specify top, left, bottom, and right padding (i.e. the dimensions of your images).

enter image description here

The second argument specifies whether the regions are stretched or tiled.



Stretch
Stretched border

Ceramic
Tiled border

To use it, you would do something similar to

UIImage *myFullImage = [UIImage imageNamed:@"nameOfTheCombinedImage"];
UIImage *resizableImage = 
[myFullImage resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right)resizingMode:UIImageResizingModeTile];

      

(stretched vs tiles "borrowed" from here )

+26


source







All Articles