在iPhone应用程序中手动绘制渐层? [英] Manually drawing a gradient in iPhone apps?

查看:125
本文介绍了在iPhone应用程序中手动绘制渐层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有两个UIColors,在一个任意大小的区域之间绘制一个均匀的渐变的最好的方法?

If I have two UIColors, what's the best way to draw an even gradient between them over an arbitrarily-sized area?

我猜你会创建一个UIView子类并在drawRect方法中使用CG绘图方法。我只是不知道哪些,或者如果有任何陷阱要注意,像表演。有没有人这样做?

I am guessing you would create a UIView subclass and use the CG drawing methods in the drawRect method. I just don't know which ones, or if there are any pitfalls to watch out for, like performance. Has anyone done this?

推荐答案

你会想使用CGGradient。请参阅iPhone开发中心 CGGradient Reference 文档。

You'll want to use CGGradient. See the iPhone Dev Center "CGGradient Reference" document.

这篇关于在iPhone应用程序中手动绘制渐层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆