iOS 渐变文字效果
来源:互联网 发布:java系统监控框架 编辑:程序博客网 时间:2024/06/06 08:11
func setGradientText() -> Void { titlDb = createLabel(rect: CGRect.init(x: 0, y: 0, width: 100, height: 100), text: "这是一个label"); titlDb.textColor = UIColor.green; titlDb.font = fontSize(size: 20); titlDb.layer.backgroundColor = UIColor.clear.cgColor; maskLayer = CAGradientLayer(); maskLayer.frame = CGRect.init(x: 100, y: 100, width: 100, height: 100); maskLayer.colors = [UIColor.red.cgColor,UIColor.green.cgColor,UIColor.orange.cgColor,UIColor.blue.cgColor,UIColor.brown.cgColor]; maskLayer.type = kCAGradientLayerAxial; maskLayer.backgroundColor = UIColor.clear.cgColor; maskLayer.startPoint = CGPoint.zero; maskLayer.endPoint = CGPoint(x: 1, y: 1); maskLayer.mask = titlDb.layer; self.view.layer.addSublayer(maskLayer); } var titlDb: UILabel! var maskLayer: CAGradientLayer!
注意几点:
titleDb是UILabel 并且必须清除背景,layer.frame和maskLayer.frame大小一样,并且layer.frame的原点是0,0;
阅读全文
0 0
- iOS 渐变文字效果
- iOS 镂空文字效果
- ios 渐变
- iOS:渐变
- 在ios中实现图片环绕文字效果
- IOS UILabel 的使用及文字效果
- ios颜色渐变
- ios 颜色渐变效果
- IOS 颜色渐变
- IOS 添加渐变色
- iOS 实现渐变色
- 颜色渐变 ios
- ios 渐变色
- iOS绘制颜色渐变
- ios颜色渐变
- ios 渐变色
- iOS 渐变色
- iOS 颜色渐变
- stm32学习笔记 F1系列GPIO相关寄存器的配置
- Asynchronous Timewarp ATW原理
- mac 搭建ELk(三)
- hbase通过mapreduce进行数据导入迁移报错
- 观察者模式
- iOS 渐变文字效果
- DMA概论
- 深度学习-基于softmax神经网络分类的源码实现
- linux中的守护进程daemon
- hibernate 单向many to one
- 运放块输出失调电压消除,只需一个电阻
- webpack--概念4--loader
- [洛谷 1144]最短路计数---spfa+记忆化搜索
- C语言执行时进行窗口隐藏