Create a border around UIImageView using 8 images(使用 8 个图像在 UIImageView 周围创建边框)
问题描述
我制作了 8 个图像,每个角 4 个图像,UIImageView
的每个边 4 个图像.现在,我到底如何让它们绕过" view
以便它们形成一个漂亮的、可拉伸的边框,就像这样(白线是我尝试实现的边框):
关于如何基于 8 个预设图像实现 view
的边框有什么想法吗?
我不想绘制边框,我想使用我的 8 张图片!
这不是你真正想要的,但这是最接近你想要做的解决方案.
您应该将 8 张图片组合成一张图片,然后使用 借用"的拉伸与平铺图像)
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):
Any ideas on how do you implement a border of a view
based on 8 preset images?
EDIT: I don't want to draw the border, I want to use my 8 images!
It is not really what you are asking for but this is the solution closest to what you are trying to do.
You should take your 8 images and combine them into one single image and then make a resizable image out of that using resizableImageWithCapInsets:resizingMode:
.
The first arguments lets you specify the top, left, bottom and right inset (i.e. the sizes of your images).
The second argument determines if the areas are stretched or tiled.
Stretched
Tiled
So 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 images "borrowed" from here)
这篇关于使用 8 个图像在 UIImageView 周围创建边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 8 个图像在 UIImageView 周围创建边框


- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01