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. 这个是历史原因造成的. ...
随机推荐
- 《转》python 10 集合
自 http://www.cnblogs.com/BeginMan/p/3160565.html 一.目录 1.集合概述 2.关于集合的操作符.关系符号 3.集合的一系列操作(添加.更新.访问.删除) ...
- C++数据类型之字符型&转义字符
字符型 **作用:** 字符型变量用于显示单个字符 **语法:** char ch = 'a'; > 注意1:在显示字符型变量时,用单引号将字符括起来,不要用双引号 > 注意2:单引号内 ...
- _IRP struct
Windows XP x86 +0x000 Type : Int2B +0x002 Size : Uint2B +0x004 MdlAddress : Ptr32 _MDL +0x000 Next : ...
- Java 仓储模式
使用的Spring boot +Jpa 项目层级: common里包含了model,以及一些viewModel等等 下面就是设计的仓储模式 先看下SysUser: @MappedSuperclass ...
- Vultr IP被墙该怎么办
我们创建好Vultr服务器时候,首先需要检测IP地址是否可用,很多IP在国内被墙,导致使用Xshell连接不上,虽然IP能够ping通,但是SSH依然连接不上.那Vultr IP被墙该怎么办呢? 方法 ...
- bcolz
raise Exception("this is an ex") bcolz总结: 0.需要用bcolz的columns需要为ndarray的列,不能直接拿list去赋值,因为我发 ...
- C/C++ 字符、字符串转十六进制(支持中文字符串转换)
#include <string> // std::string #include <sstream> // std::stringstream /** * #purpose ...
- 【题解】洛谷 P1061 Jam的计数法
#include <iostream> #include <cstring> #include <cstdio> using namespace std; int ...
- SSH整合时执行hibernate查询报错:java.lang.ClassCastException: com.ch.hibernate.Depart
今天在整合ssh三个框架时,有一个功能,是查询所有员工信息,且员工表和部门表是多对一的映射关系,代码能正常运行到查询得到一个List集合,但在页面展示的时候,就报异常了, java.lang.Clas ...
- LightOJ-1138-Trailing Zeroes (III)-二分+求N!末尾0
You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in d ...