RCLighting

https://github.com/RidgeCorn/RCLighting

效果:

真机测试的效率:

看了源码,其实原理很简单:

================================

1. 实现UIView的category

2. 继承了一个CALayer

3. 将这个继承的CALayer插入到UIView的subLayer中

4. 对这个layer进行动画操作

================================

源码:

//
// RootViewController.m
// Lighting
//
// Copyright (c) 2014年 Y.X. All rights reserved.
// #import "RootViewController.h"
#import "RCLighting.h" @interface RootViewController () @end @implementation RootViewController - (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor]; // 辉光view
UIView *showView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
showView.alpha = 0.8f;
showView.backgroundColor = [UIColor redColor];
showView.center = self.view.center;
[self.view addSubview:showView];
[showView showLightingWithColors:@[[UIColor brownColor],
[UIColor greenColor],
[UIColor cyanColor],
[UIColor orangeColor],
[UIColor purpleColor],
[UIColor magentaColor],
[UIColor redColor],
[UIColor yellowColor],
[UIColor blueColor]]]; // 中间显示字体
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.font = [UIFont fontWithName:@"HelveticaNeue-UltraLight"
size:.f];
label.text = @"YouXianMing";
label.center = self.view.center;
[self.view addSubview:label];
} @end

注意哦,源码中有用到POP库动画

RCLighting的更多相关文章

随机推荐

  1. h2数据库的简单使用

    1.登录H2数据库的WebConsole控制台 2.设置数据库连接 3.连接测试通过之后,点击[连接]按钮,登录到test数据库的webConsole 4.创建表 复制H2数据库提供的样例SQL脚本, ...

  2. 【数组】Unique Paths

    题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...

  3. 【树】Validate Binary Search Tree

    需要注意的是,左子树的所有节点都要比根节点小,而非只是其左孩子比其小,右子树同样.这是很容易出错的一点是,很多人往往只考虑了每个根节点比其左孩子大比其右孩子小.如下面非二分查找树,如果只比较节点和其左 ...

  4. 深入理解系列之 float

    float的设计初衷: 仅仅是为了实现文字环绕效果 float的感性认知: 包裹性: 收缩:元素应用了float后,宽度收缩,紧紧地包裹住内容(即元素的宽度收缩到元素内的内容的宽度大小 坚挺:原来没有 ...

  5. JavaScript数据结构-4.栈操作

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. Python DataFrame导出CSV、数据库

    写入Oracle from sqlalchemy import create_engine import pandas as pd import numpy as np df = pd.DataFra ...

  7. Python(2):创建函数模块

    说明: 在使用python的时候我们除了使用内置的函数之外,可能还需要使用一些别人写的函数.或者我们写的代码也希望可以给其他人使用.要实现这样的功能,我们就需要按照下面的步骤来定义自己的模块: Ste ...

  8. IOS项目之分层MVVM

    在做.Net时,有用到三层架构,使项目分层.ios项目使用AFNetWork把网络层这块也放进了ViewController中,数据解析缓存这些也在里面,这样层次结构可能不够清楚,今天就试着分离了一下 ...

  9. [转]Format a ui-grid grid column as currency

    本文转自:https://stackoverflow.com/questions/27747184/format-a-ui-grid-grid-column-as-currency-rc-3-0 Yo ...

  10. TabControl 选项卡控件

    TabControl 控件是由System.Windows.Forms.TabControl类提供的,作用就是讲相关的组件组合到一系列选项卡页面上.   MulitiLine 属性用来设置是否显示多行 ...