简体   繁体   English

我想在UIView上绘制自定义形状如苹果形状

[英]I want to draw custom shape like apple shape on UIView

I am trying to make Apple kind of shape for progressHUD. 我正在尝试使Apple更具进步性。 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... 我可以选择使用.png图片,但是我不能,因为我必须根据百分比状态用不同的颜色填充苹果Shape。我正在使用UIView 绘制此形状...

  • 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 我可以选择使用.png图片,但不能

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!): 使用这种方法,我花了大约30秒钟来创建此结果(将您的苹果形艺术品用作.png图像!):

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM