UIView上的渐变和iPhone上的UILabels我的应用程序需要在UIView或UILabel但是背景必须是渐变,而不是真实的。UIColor..使用图形程序创建所需的外观是不好的,因为文本可能会根据从服务器返回的数据而有所不同。有谁知道处理这件事最快的方法吗?非常感谢你的想法。
3 回答

慕虎7371278
TA贡献1802条经验 获得超4个赞
您还可以使用一个像素宽的图形图像作为渐变,并设置View属性来扩展图形以填充视图(假设您正在考虑的是一个简单的线性梯度,而不是某种径向图形)。

慕仙森
TA贡献1827条经验 获得超8个赞
CAGradientLayer
:
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease]; CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = view.bounds; gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil]; [view.layer insertSublayer:gradient atIndex:0];
- 3 回答
- 0 关注
- 268 浏览
添加回答
举报
0/150
提交
取消