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 周围创建边框
基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01