I have 8 images I made, 4 images for each of the corners, and 4 images for each of the sides of UIImageView
. Now, how on Earth do I make them 'come around' the view
so they form a nice-looking, stretchable border, something like this (the white line is the border I try to implement):
![enter image description here](https://i.stack.imgur.com/LlJ9p.png)
关于如何实现边界的任何想法view
基于 8 个预设图像?
EDIT:我不想draw边框,我想使用我的 8 张图像!
这并不是您真正要求的,但这是最接近您想要做的解决方案。
您应该将 8 张图像组合成一张图像,然后使用该图像制作一张可调整大小的图像resizableImageWithCapInsets:resizingMode:.
第一个参数允许您指定顶部、左侧、底部和右侧插图(即图像的大小)。
![enter image description here](https://i.stack.imgur.com/quRfM.png)
第二个参数确定区域是拉伸还是平铺。
Stretched
![Stretched border](https://i.stack.imgur.com/CDDUs.gif)
Tiled
![Tiled border](https://i.stack.imgur.com/OPfHT.gif)
所以要使用它你会做类似的事情
UIImage *myFullImage = [UIImage imageNamed:@"nameOfTheCombinedImage"];
UIImage *resizableImage =
[myFullImage resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right)resizingMode:UIImageResizingModeTile];
(拉伸与平铺图像“借用”自here)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)