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属性简介和使用的更多相关文章

  1. iOS之CAScrollLayer属性简介和使用

    1.CAScrollLayer的简介 CAScrollLayer用于显示一个滑动图层的一部分,可以确定滑动方向和可视区域面积,限制不滑出区域外!相关属性如下:其中 /* Scroll the cont ...

  2. iOS之CAReplicatorLayer属性简介和使用

    1.CAReplicatorLayer简介 CAReplicatorLayer用于对图层进行复制,包括图层的动画也能复制!可以看着将某一段事务进行重复! #import <QuartzCore/ ...

  3. iOS之CALayer属性简介

    /* CoreAnimation - CALayer.h Copyright (c) 2006-2017, Apple Inc. All rights reserved. */ #import < ...

  4. iOS之CATextLayer属性简介

    1.CATextLayer简介 CATextLayer快速高效简单地来渲染纯文本.NSAttributedString /* The text layer provides simple text l ...

  5. iOS之CAShapeLayer属性简介

    1.CAShapeLayer需要和贝塞尔曲线一块使用! #import <QuartzCore/CALayer.h> NS_ASSUME_NONNULL_BEGIN CA_CLASS_AV ...

  6. iOS开发-automaticallyAdjustsScrollViewInsets属性

    iOS开发-automaticallyAdjustsScrollViewInsets属性 Available in iOS 7.0 and later. 简单点说就是automaticallyAdju ...

  7. HTML5 Audio and Video 的新属性简介

    前言:HTML5 中 Audio and Video的使用方法比较简单,但就是比较复杂,方法属性多.如果不常用的几乎难以记住,甚至有些人难以区分不同属性和方法的作用,更别说应用了.以下对Audio a ...

  8. IOS UITableView NSIndexPath属性讲解

    IOS UITableView NSIndexPath属性讲解   查看UITableView的帮助文档我们会注意到UITableView有两个Delegate分别为:dataSource和deleg ...

  9. IOS学习5——属性与成员变量

    [转]iOS中属性与成员变量的区别 ios中属性修饰符的作用 1. 属性用property声明 2. 简而言之,对于目前的ios开发,属性和成员变量的区别,完全可以不管. 3. 这个是历史原因造成的. ...

随机推荐

  1. jdk源码阅读

    转载https://www.cnblogs.com/mh-study/p/10078548.html 1.java.lang 1) Object 12) String 13) AbstractStri ...

  2. Aop 简单实例

    一 , 定义aop @Aspect @Component public class MyAspect { //* com 这里有个 空格 ! @Pointcut("execution(* c ...

  3. [NOIP2005] 过河【Dp,思维题,缩点】

    Online Judge:Luogu P1052 Label:Dp,思维题,缩点,数学 题目描述 在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧.在桥上有一些石子,青蛙很讨厌踩在这些石子 ...

  4. expect安装

    expect是在tcl基础上创建起来的,因此在安装expect之前需要安装tcl 安装TCL下载地址:http://www.tcl.tk/software/tcltk/download.html[ro ...

  5. sql (4) key and Join

    新建表: "Persons" 表:Id_P LastName FirstName Address City1 Adams John Oxford Street London2 Bu ...

  6. sql语句之条件,分页,排序

    sql语句之条件,分页,排序

  7. SQL Server 添加数据库没有权限等

    { 在安装好sql 后 第一次需要用windows 方式登陆 1.创建一个宁外一个登陆名登陆 在安全->登陆名 2.给此登陆属性的服务器角色添加sysadmin权限 //尽情享受!!! }

  8. XAMPP的安装及使用教程

    https://blog.csdn.net/qq_36595013/article/details/80373597#3%E9%85%8D%E7%BD%AEapache

  9. MFC文档视图结构学习笔记

    文档/视图概述 为了统一和简化数据处理方法,Microsoft公司在MFC中提出了文档/视图结构的概念,其产品Word就是典型的文档/视图结构应用程序 MFC通过其文档类和视图类提供了大量有关数据处理 ...

  10. 正则表达式 判断内容是否为合法的url

    var strUrl= "^((https|http|ftp|rtsp|mms)?://)" + "?(([0-9a-z_!~*'().&=+$%-]+: )?[ ...