如何以编程方式为UIButtons提供光泽外观?

编程入门 行业动态 更新时间:2024-10-27 04:36:09
本文介绍了如何以编程方式为UIButtons提供光泽外观?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想为一些iPhone UIButtons添加3D或光泽外观,但不使用PNG或可伸缩图像。我有很多不同形状和大小的按钮,它们具有许多在运行时生成的颜色,因此预渲染的图像在我的情况下是不可行的。

I would like to add 3D or glossy look to some iPhone UIButtons, but do so without the use of PNGs or stretchable images. I have a lot of buttons of varying shapes and sizes with lots of colors which are generated on the fly, so prerendered images are not feasible in my case.

请以编程方式在这些按钮上绘制光泽?

How would you go about drawing the gloss on these buttons programmatically?

推荐答案

在这个答案,我提供一些代码在UIView绘制光泽渐变,但

In this answer, I provide some code for drawing a gloss gradient over a UIView, but Mirko's answer to that same question shows a more performant way of doing this.

我创建了一个更加精细的3-D按钮风格,光泽和阴影,作为我的课程的一个例子。该3-D按钮的代码是软件包的一部分,可以从下载(查找MATCGlossyButton UIButton子类)。我在 iTunes U 。

I created a more elaborate 3-D button style, with gloss and shadowing, as an example for my course. The code for that 3-D button is part of the package that can be downloaded here (look for the MATCGlossyButton UIButton subclass). I describe the drawing of this element in the video for the Quartz 2D class from the spring semester of my iPhone development course on iTunes U.

更多推荐

如何以编程方式为UIButtons提供光泽外观?

本文发布于:2023-07-27 05:24:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1220591.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:光泽   外观   方式   UIButtons

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!