产生渐变色的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的更多相关文章

  1. [控件] AngleGradientView

    AngleGradientView 效果 说明 1. 用源码产生带环形渐变色的view 2. 可以配合maskView一起使用 (上图中的右下角图片的效果) 源码 https://github.com ...

  2. cocos2D(六)----CCLayer

    一个游戏中能够有非常多个场景,每一个场景里面又可能包括有多个图层,这里的图层一般就是CCLayer对象.CCLayer本身差点儿没什么功能.对照CCNode,CCLayer可用于接收触摸和加速计输入. ...

  3. 自定义进度条渐变色View

    package com.jianke.stepCounter.Activity; import android.annotation.SuppressLint; import android.cont ...

  4. view渐变色,透明度渐变

    1 功能描述 开发中经常遇到这样的需求:view2显示在view1上面,透过view2可以渐渐的看到view1.效果如图1所示:view1是一个imageView,view2是一个普通view.vie ...

  5. 通过CAGradientLayer制作渐变色效果(转)

    转载自:http://blog.it985.com/7986.html 看了极客学院的视频之后写的一篇博客,觉得不错,还是作为笔记使用. 简单介绍一下CAGradientLayer吧. Gradien ...

  6. Android custom View AirConditionerView hacking

    package com.example.arc.view; import android.content.Context; import android.graphics.Canvas; import ...

  7. 自定义View(1)简单流程及示例模板

    1,继承View , ViewGroup,或TextView等等 2,绘制相关的api, canvas 画布, paint 画笔 2,重写重要的函数(注意这个顺序) onMeasure 属于View的 ...

  8. 转载爱哥自定义View系列--Paint详解

    上图是paint中的各种set方法 这些属性大多我们都可以见名知意,很好理解,即便如此,哥还是带大家过一遍逐个剖析其用法,其中会不定穿插各种绘图类比如Canvas.Xfermode.ColorFilt ...

  9. android shape的使用详解以及常用效果(渐变色、分割线、边框、半透明阴影效果等)

    shape使用.渐变色.分割线.边框.半透明.半透明阴影效果. 首先简单了解一下shape中常见的属性.(详细介绍参看  api文档 ) 转载请注明:Rflyee_大飞: http://blog.cs ...

随机推荐

  1. ELK构建MySQL慢日志收集平台详解

    上篇文章<中小团队快速构建SQL自动审核系统>我们完成了SQL的自动审核与执行,不仅提高了效率还受到了同事的肯定,心里美滋滋.但关于慢查询的收集及处理也耗费了我们太多的时间和精力,如何在这 ...

  2. 16-hadoop-mapreduce简介

    mapreduce是hadoop的核心组件, 设计理念是移动计算而不是移动数据, mapreduce的思想是'分而治之', 将复杂的任务分解成几个简单的任务去执行 1, 数据和计算规模大大减少 2, ...

  3. JS的可枚举性

        在学习ES6的过程中,涉及到遍历方法时,提到过可枚举性,且多种遍历方法都与可枚举性相关.本章节,将总结这些遍历方法的可枚举性,并在必要的部分,给出对比实例. 一.设置属性的可枚举性 在上一文章 ...

  4. Mybatis中同时使用shardbatis和pagehelper插件冲突问题

    在一次使用mybatis的插件,分表shardbatis+分页pagehelper共同使用的时候,会抛出以下异常: java.lang.NoSuchMethodError: net.sf.jsqlpa ...

  5. Redis高可用升级

    前言: 缓存对应实时性要求比较高的业务需求可谓十分重要,但缓存中的实时数据一旦丢失,将直接影响整个业务功能.考虑到各场景的业务需求,redis推出了高可用的方案,即:主从+哨兵的HA机制. 准备 &q ...

  6. Python装饰器之 property()

    1. 何为装饰器? 官方定义:装饰器是一个很著名的设计模式,经常被用于有切面需求的场景,较为经典的有插入日志.性能测试.事务处理等.装饰器是解决这类问题的绝佳设计,有了装饰器,我们就可以抽离出大量函数 ...

  7. 利用OpenCV检测手掌(palm)和拳头(fist)

    思路:利用训练好的palm.xml和fist.xml文件,用OpenCV的CascadeClassifier对每一帧图像检测palm和fist,之后对多帧中检测到的palm和fist进行聚类分组,满足 ...

  8. Microsoft.AspNet.Identity 的简单使用

    要完成一个简单的注册,登陆,至少需要实现Identity中的3个接口 IUser IUserStore<TUser> : IDisposable where TUser : IUser I ...

  9. Spring学习之路

    (一)搭建Spring.NET环境常见的DLL 1.spring.core --整个框架的基础,实现了依赖注入的功能 2.Spring.AOP--提供面向方面编程(aop)的支持 3.Spring.D ...

  10. win7下使用IIS服务器及自定义服务器端包含模块(SSI)步骤

    配置完过段时间就容易忘记,特此记录. 1.开启IIS服务器. 默认没有安装,需要先安装. 打开控制面板–> 打开“程序和功能”–> 左侧选择“启用或关闭windows功能”–> 找到 ...