产生渐变色的view
产生渐变色的view

效果

源码
https://github.com/YouXianMing/UI-Component-Collection
//
// GradientColorView.h
// GradientColorView
//
// Created by YouXianMing on 15/12/15.
// Copyright © 2015年 YouXianMing. All rights reserved.
// #import <UIKit/UIKit.h> @interface GradientColorView : UIView /**
* CGColor's array.
*/
@property (nonatomic, strong) NSArray *colors; /**
* CGColor's location.
*/
@property (nonatomic, strong) NSArray *locations; /**
* Start point.
*/
@property (nonatomic) CGPoint startPoint; /**
* End point.
*/
@property (nonatomic) CGPoint endPoint; /**
* After you have set all the properties, you should run this method to make effective.
*/
- (void)becomeEffective; @end
//
// GradientColorView.m
// GradientColorView
//
// Created by YouXianMing on 15/12/15.
// Copyright © 2015年 YouXianMing. All rights reserved.
// #import "GradientColorView.h" @interface GradientColorView () @property (nonatomic, strong) CAGradientLayer *gradientLayer; @end @implementation GradientColorView + (Class)layerClass { return [CAGradientLayer class];
} - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { _gradientLayer = (CAGradientLayer *)self.layer;
self.startPoint = CGPointMake(, );
self.endPoint = CGPointMake(, );
self.locations = @[@(0.25), @(0.5), @(0.75)];
self.colors = @[(__bridge id)[UIColor redColor].CGColor,
(__bridge id)[UIColor greenColor].CGColor,
(__bridge id)[UIColor blueColor].CGColor];
} return self;
} - (void)becomeEffective { self.gradientLayer.startPoint = self.startPoint;
self.gradientLayer.endPoint = self.endPoint;
self.gradientLayer.colors = self.colors;
self.gradientLayer.locations = self.locations;
} @end
细节

产生渐变色的view的更多相关文章
- [控件] AngleGradientView
AngleGradientView 效果 说明 1. 用源码产生带环形渐变色的view 2. 可以配合maskView一起使用 (上图中的右下角图片的效果) 源码 https://github.com ...
- cocos2D(六)----CCLayer
一个游戏中能够有非常多个场景,每一个场景里面又可能包括有多个图层,这里的图层一般就是CCLayer对象.CCLayer本身差点儿没什么功能.对照CCNode,CCLayer可用于接收触摸和加速计输入. ...
- 自定义进度条渐变色View
package com.jianke.stepCounter.Activity; import android.annotation.SuppressLint; import android.cont ...
- view渐变色,透明度渐变
1 功能描述 开发中经常遇到这样的需求:view2显示在view1上面,透过view2可以渐渐的看到view1.效果如图1所示:view1是一个imageView,view2是一个普通view.vie ...
- 通过CAGradientLayer制作渐变色效果(转)
转载自:http://blog.it985.com/7986.html 看了极客学院的视频之后写的一篇博客,觉得不错,还是作为笔记使用. 简单介绍一下CAGradientLayer吧. Gradien ...
- Android custom View AirConditionerView hacking
package com.example.arc.view; import android.content.Context; import android.graphics.Canvas; import ...
- 自定义View(1)简单流程及示例模板
1,继承View , ViewGroup,或TextView等等 2,绘制相关的api, canvas 画布, paint 画笔 2,重写重要的函数(注意这个顺序) onMeasure 属于View的 ...
- 转载爱哥自定义View系列--Paint详解
上图是paint中的各种set方法 这些属性大多我们都可以见名知意,很好理解,即便如此,哥还是带大家过一遍逐个剖析其用法,其中会不定穿插各种绘图类比如Canvas.Xfermode.ColorFilt ...
- android shape的使用详解以及常用效果(渐变色、分割线、边框、半透明阴影效果等)
shape使用.渐变色.分割线.边框.半透明.半透明阴影效果. 首先简单了解一下shape中常见的属性.(详细介绍参看 api文档 ) 转载请注明:Rflyee_大飞: http://blog.cs ...
随机推荐
- unity 图片变纯色填充
unity自带shader 即可
- zk使用原理
ZooKeeper的基本原理 ZNode的基本概念 ZooKeeper数据模型的结构与Unix文件系统很类似,整体上可以看作是一棵树,每个节点称做一个ZNode.每个ZNode都可以通过其路径唯一标识 ...
- goldarch企业管理软件框架整体解决方案终于出来了
所有的图片及解决方案都在我的博客里http://blog.posn.net 框架把企业管理软件开发中要遇到的常用做了组件化处理,达到了通用性和可定制性的目的. goldarch的数据层是spring. ...
- 任务三十八:UI组件之排序表格
任务三十八:UI组件之排序表格 面向人群: 有一定JavaScript基础 难度: 低 重要说明 百度前端技术学院的课程任务是由百度前端工程师专为对前端不同掌握程度的同学设计.我们尽力保证课程内容的质 ...
- C# 中 NPOI 库读写 Excel 文件的方法【摘】
原作:淡水网志 NPOI 是开源的 POI 项目的.NET版,可以用来读写Excel,Word,PPT文件.在处理Excel文件上,NPOI 可以同时兼容 xls 和 xlsx.官网提供了一份 Exa ...
- ubuntu上使用vim编辑文本内容
1. 什么是 vim? Vim是从 vi 发展出来的一个文本编辑器.代码补完.编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用.简单的来说, vi 是老式的字处理器,不过功能已经很齐全了, ...
- Node.js学习笔记(七) --- Node.js的静态文件托管、路 由、EJS 模板引擎、GET 、POST
1 . Nodejs 静态文件托管静态 web 服务器封装 2 . 路由 官方解释: 路由(Routing)是由一个 URI(或者叫路径)和一个特定的 HTTP 方法(GET.POST 等)组成的, ...
- Centos7初次开机提示Initial setup of CentOS Linux 7 (core)
安装完成centos7后出现如下提示: Initial setup of CentOS Linux 7 (core) 1) [x] Creat user 2) [!] License informat ...
- 福州大学oj 1752 A^B mod C ===>数论的基本功。位运用。五星*****
Problem 1752 A^B mod C Accept: 579 Submit: 2598Time Limit: 1000 mSec Memory Limit : 32768 KB P ...
- 传输层协议TCP和UDP分析
分析所用软件下载:Wireshark-win32-1.10.2.exe 阅读导览 1. 分析应用TCP协议,以及TCP链接管理 2. 分析应用UDP协议 分析要求 (1)TCP部分: 学习3CDaem ...