Question

I want to stretch an image using 2 stretch areas. So I need to achieve something like this:

enter image description here

But by default in iOS I can define one rect only.

Is it possible to solve this issue without incision into 2 separate images when each of them has only one rect?

Was it helpful?

Solution

As stated, I would definitely do with 2 images. Or add a category on top of UIImage which does your job. The key is what kind of parameter will you give to the method?

OTHER TIPS

The only thing which iOS provides out of the box is (as described in this post)

// Image with cap insets
UIImage *image = [[UIImage imageNamed:@"image"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 16, 0, 16)];

There is no way to do what you are referring to without splitting the image, or writing a custom image rendering UIView subclass. You should be careful if going with the later as you will be throwing away a lot of optimisations present in UIImageView.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top