iOS之CAGradientLayer属性简介和使用
1、CAGradientLayer简介
CAGradientLayer用于制作背景图层的颜色渐变,也就是颜色梯度!相关属性简介:
#import <QuartzCore/CALayer.h>
#import <Foundation/NSArray.h> NS_ASSUME_NONNULL_BEGIN CA_CLASS_AVAILABLE (10.6, 3.0, 9.0, 2.0)
@interface CAGradientLayer : CALayer //颜色数组 CGColor
@property(nullable, copy) NSArray *colors; //颜色区间范围数组,范围是[0-1]并且是递增
@property(nullable, copy) NSArray<NSNumber *> *locations; //开始坐标和结束坐标 范围(0-1)
//默认值(0.5,0.0) (0.5,1.0)
@property CGPoint startPoint;
@property CGPoint endPoint; //绘制类型,目前只有一个参数也是默认值kCAGradientLayerAxial
@property(copy) NSString *type; @end /** `type' values. **/ CA_EXTERN NSString * const kCAGradientLayerAxial
CA_AVAILABLE_STARTING (10.6, 3.0, 9.0, 2.0); NS_ASSUME_NONNULL_END
2、CAGradientLayer的简单使用:
self.showView = [[UIView alloc] initWithFrame:CGRectMake(,(CScreenHeight-)/,CScreenWidth-,)];
CAGradientLayer *layer = [CAGradientLayer layer];
layer.frame = CGRectMake(,,CScreenWidth-,);
layer.colors = @[(id)UIColor.redColor.CGColor,
(id)UIColor.whiteColor.CGColor,
(id)UIColor.redColor.CGColor];
layer.locations = @[@(-0.2),@(-0.1),@];
layer.startPoint = CGPointMake(, );
layer.endPoint = CGPointMake(, );
layer.type = kCAGradientLayerAxial;
[self.showView.layer addSublayer:layer];
self.layer = layer;
self.showView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.showView];
self.waterTimer = [NSTimer scheduledTimerWithTimeInterval: target:self selector:@selector(waterAction) userInfo:nil repeats:YES]; - (void)waterAction{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"locations"];
animation.fromValue = @[@(-0.3), @(-0.2), @()];
animation.toValue = @[@(1.0), @(1.2), @(1.3)];
animation.duration = ;
[self.layer addAnimation:animation forKey:nil];
}
效果图
iOS之CAGradientLayer属性简介和使用的更多相关文章
- iOS之CAScrollLayer属性简介和使用
1.CAScrollLayer的简介 CAScrollLayer用于显示一个滑动图层的一部分,可以确定滑动方向和可视区域面积,限制不滑出区域外!相关属性如下:其中 /* Scroll the cont ...
- iOS之CAReplicatorLayer属性简介和使用
1.CAReplicatorLayer简介 CAReplicatorLayer用于对图层进行复制,包括图层的动画也能复制!可以看着将某一段事务进行重复! #import <QuartzCore/ ...
- iOS之CALayer属性简介
/* CoreAnimation - CALayer.h Copyright (c) 2006-2017, Apple Inc. All rights reserved. */ #import < ...
- iOS之CATextLayer属性简介
1.CATextLayer简介 CATextLayer快速高效简单地来渲染纯文本.NSAttributedString /* The text layer provides simple text l ...
- iOS之CAShapeLayer属性简介
1.CAShapeLayer需要和贝塞尔曲线一块使用! #import <QuartzCore/CALayer.h> NS_ASSUME_NONNULL_BEGIN CA_CLASS_AV ...
- iOS开发-automaticallyAdjustsScrollViewInsets属性
iOS开发-automaticallyAdjustsScrollViewInsets属性 Available in iOS 7.0 and later. 简单点说就是automaticallyAdju ...
- HTML5 Audio and Video 的新属性简介
前言:HTML5 中 Audio and Video的使用方法比较简单,但就是比较复杂,方法属性多.如果不常用的几乎难以记住,甚至有些人难以区分不同属性和方法的作用,更别说应用了.以下对Audio a ...
- IOS UITableView NSIndexPath属性讲解
IOS UITableView NSIndexPath属性讲解 查看UITableView的帮助文档我们会注意到UITableView有两个Delegate分别为:dataSource和deleg ...
- IOS学习5——属性与成员变量
[转]iOS中属性与成员变量的区别 ios中属性修饰符的作用 1. 属性用property声明 2. 简而言之,对于目前的ios开发,属性和成员变量的区别,完全可以不管. 3. 这个是历史原因造成的. ...
随机推荐
- Redis连不上的一些细节配置
远程链接redis连不上,在确保防火墙设置正确的情况下 把redis.conf中的 bind 127.0.0.1注释 另外把protected-mode yes 改为protected-mode no
- 2018-8-10-WPF-使用-Direct2D1-画图-绘制基本图形
title author date CreateTime categories WPF 使用 Direct2D1 画图 绘制基本图形 lindexi 2018-08-10 19:16:53 +0800 ...
- windows 10 无法启动 windows update 服务 错误 0x80070005 拒绝访问
windows 10 无法启动 windows update 服务 错误 0x80070005 拒绝访问: 解决方法: 首先重命名系统盘 windows目录下的代号为“SoftwareDistribu ...
- Redis问题整理
Redis问题总结 1.单点登录的两个项目cookie不一致 由于在配置自定义Cookie的时候 @Bean("shiroCookie") public SimpleCookie ...
- 一个有关group by的错误
事例:查询有奖金的每个部门的部门名和部门的领导编号和该部门的最低工资 SELECT department_name,MIN(salary),departments.manager_idFROM dep ...
- java 和 IntelliJ IDEA 的一些配置
jdk 的下载与配置https://jingyan.baidu.com/article/ca41422fe3b7261eae99edc6.html intellij IDEA软件java项目No SD ...
- Java怎样实现解析身份证号
身份证号解析,demo /** * 身份证号解析demo * */ public class TestArea { public static void main(String[] args) { S ...
- Altera FPGA– Bit Slip
通过在接收端加延时,在延时间隙插入'0'或'1',以使最终接收和期望数据一致. BitSlip操作要注意几点: 1,BitSlip操作在rx_bitslip的上升沿即开始: 2,BitSlip操作开始 ...
- day22 yield的表达式的应用,面向过程编程,内置函数前几个
Python之路,Day10 = Python基础10 生成器表达式: (i for i in range(10) if i > 5)os.walk(r'文件路径')返回一个迭代器, 第一次ne ...
- 期望dp+高斯消元——bzoj3143
比较经典的题,题解看网上的..https://www.cnblogs.com/GXZlegend/p/7054536.html 自己sort弄错了..还以为是高斯消元写歪了.. #include< ...