質問

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