“Beveled” Shapes in Quartz 2D

寵の児 提交于 2020-01-04 09:13:50

问题


I'm familiar with some of the basics of Quartz 2D drawing, like drawing basic shapes and gradients and so on, but I'm not sure how to draw a shape with a "beveled" look, like this:

beveled circle http://www.shaggyfrog.com/junk/beveled-circle.jpg

Essentially we've got a shine on one corner, and maybe some shading in the opposite corner. I think -- I didn't make this image, although I'd like to be able to approximate it.

Any ideas? This is on the iPhone, and I'd like to use built-in frameworks and avoid any external libraries if at all possible.


回答1:


There are really only a few useful approaches you can take to this problem.

  1. Use your basic shape drawing techniques and combine them with a one or more gradient curves. (Implicit object construction) with curves/fills.

  2. Custom build a UIView and build the object up per-pixel in a drawRect.

  3. Pre-render your beveled/shadowed shapes and load them into an image and blit them into a UIImageView.



来源:https://stackoverflow.com/questions/2135843/beveled-shapes-in-quartz-2d

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