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

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

问题描述

我正在尝试为 progressHUD 制作 Apple 形状.我可以选择使用 .png Image 但我不能因为我必须用不同的颜色填充苹果形状取决于百分比状态..我正在使用 UIView绘制这个形状...

  • 我想建议如何轻松画出苹果的形状?
  • 我们如何用不同的颜色填充半色?

解决方案

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

是的,你可以.— 拿一些苹果形的艺术品.将其用作掩码 - 它会在视图中打一个洞.现在在它后面放另一个视图,带有颜色.现在苹果看起来就是那种颜色,因为通过苹果形的孔可以看到那种颜色.现在把另一个视图放在它后面,用不同的颜色,向上或移动适当的量,以便将透过苹果看到的东西分成两种颜色.>

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

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 want suggestion how to draw apple kind of shape easily?
  • And How we can fill half colour with different colour?

解决方案

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.

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天全站免登陆