将边框应用于图像形状 [英] Applying border to image shape

查看:87
本文介绍了将边框应用于图像形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有各种不同形状的图像。像树,云。 (附上样本图像)。
我想以编程方式为这些形状添加边框。就像图像是树,然后需要突出树形状。
我不能使用calayer,因为它会将边框应用于UIImageView。
任何人都可以指导我如何实现这个目标吗?

In my application I am having various images of different different shapes. Like tree, cloud. (Sample image is attached). I want to add border to those shapes pro-grammatically. Like if image is of tree then need to highlight tree shape. I cannot use calayer as it will apply border to UIImageView. Can anyone guide me how to achieve this?

推荐答案

简单的选项是绘制图像两次,首先应用小比例来生长图像一点。如果图像不透明(但是是黑色和白色),则屏蔽。

Simple option is to draw the image twice, first with a small scale applied to grow the image a little. Masking if the images aren't transparent (but are black&white).

这篇关于将边框应用于图像形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆