UIView和UILabels上的渐变在iPhone [英] Gradients on UIView and UILabels On iPhone
问题描述
可能重复:
在iPhone应用程序中手动绘制渐变
我的应用程序需要在 UIView
或 UILabel
中显示文本,但是背景必须是渐变到真实的 UIColor
。使用图形程序创建所需的外观是不好的,因为文本可能会根据从服务器返回的数据而有所不同。
My application needs to display text in either a UIView
or UILabel
but the back ground must be a gradient as opposed to a true UIColor
. Using a graphics program to create desired look is no good as the text may vary depending on data returned from a server.
有没有人知道最快的方法来解决这个问题?
Does anyone know the quickest way to tackle this? Your thoughts are greatly appreciated.
推荐答案
您还可以使用一个像素宽的图形图像作为渐变,设置视图属性以展开图形以填充视图(假设您正在考虑一个简单的线性渐变,而不是某种径向图形)。
You could also use a graphic image one pixel wide as the gradient, and set the view property to expand the graphic to fill the view (assuming you are thinking of a simple linear gradient and not some kind of radial graphic).
这篇关于UIView和UILabels上的渐变在iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!