如何向UIView添加径向渐变? [英] How do I add a radial gradient to a UIView?

查看:105
本文介绍了如何向UIView添加径向渐变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIView 我想要一个径向渐变,我想知道如何去做这个?

I have a UIView which I want to have a radial gradient, and I'm wondering how to go about doing this?

推荐答案

要执行此操作,您需要下载到Core Graphics并使用 CGContextDrawRadialGradient

To do this you need to drop down to Core Graphics and use CGContextDrawRadialGradient.

类似Stack Overflow问题

如何绘制径向渐变(iphone)扇区

How to draw a gradient line (fading in/out) with Core Graphics/iPhone?

其他资源

有一个教程展示如何绘制图标iOS上的渐变:

There's a tutorial showing how to draw icons with gradients on iOS here:

http://redartisan.com/2011/05/13/porting-iconapp-core-graphics

他把代码放在Github上,完成了一个UIView子类,它显示了使用Core Graphics制作渐变的(相当漫长的)方式:

He's put the code on Github, complete with a UIView subclass that shows the (rather longwinded) way of making gradients using Core Graphics:

https://github.com/crafterm/IconApp/blob/master/IconApp/IconView.m

这篇关于如何向UIView添加径向渐变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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