문제

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?

도움이 되었습니까?

해결책

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?

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top