I want to draw custom shape like apple shape on UIView

我怕爱的太早我们不能终老 提交于 2019-12-28 19:36:43

问题


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?

回答1:


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!):



来源:https://stackoverflow.com/questions/29553552/i-want-to-draw-custom-shape-like-apple-shape-on-uiview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!