我想在UIView上绘制像苹果形状的自定义形状 [英] I want to draw custom shape like apple shape on UIView

查看:340
本文介绍了我想在UIView上绘制像苹果形状的自定义形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使Apple成为progressHUD的形状。我可以选择使用.png图像,但我不能因为我必须用不同的颜色填充苹果形状取决于百分比状态..我使用 UIView 绘制这个形状...

I am trying to make Apple kind of shape for progressHUD. I have option to use .png Image but I cant because I have to fill the apple Shape with different colour depends of percentage status.. I am using UIView to draw this shape...


  • 我想建议如何轻松地绘制苹果形状?

  • 以及如何我们可以填充不同颜色的半色?

推荐答案


I可以选择使用.png图片,但我不能

I have option to use .png Image but I cant

是的,你可以。 - 抓住一些苹果形状的艺术品。将它用作面具 - 它在视图中打孔。现在用一种颜色把它背后的另一个视图。现在苹果似乎是那种颜色,因为通过苹果形状的洞可以看到这种颜色。现在将另一个视图置于其后面,使用不同的颜色,然后将其向上或向右移动,以便将通过苹果看到的内容划分为两种颜色。

Yes, you can. — Get hold of some apple-shaped artwork. Use it as a mask - it punches a hole in a view. Now put another view behind it, with a color. Now the apple appears to be that color, because that color is being seen through the apple-shaped hole. Now put another view behind it, with a different color, and move it up or across the right amount so as to divide what's seen through the apple into two colors.

使用这种方法,我花了大约30秒来创建这个结果(使用你的苹果形艺术品作为 .png image!):

Using that approach, it took me about 30 seconds to create this result (using your apple-shaped artwork as a .png image!):

这篇关于我想在UIView上绘制像苹果形状的自定义形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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