zoukankan      html  css  js  c++  java
  • RCLighting

    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(0, 0, 200, 50)];
        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(0, 0, 300, 100)];
        label.textAlignment = NSTextAlignmentCenter;
        label.textColor     = [UIColor whiteColor];
        label.font          = [UIFont fontWithName:@"HelveticaNeue-UltraLight"
                                              size:30.f];
        label.text          = @"YouXianMing";
        label.center        = self.view.center;
        [self.view addSubview:label];
    }
    
    @end

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

  • 相关阅读:
    Git中tag标签的使用
    antd vue Layout 组件收缩展开自定义
    antd vue Popover气泡卡片的使用
    antd vue Tree树形控件的使用
    antd vue Message 全局提示的使用
    tp5.1 关联条件查询haswhere 用field限制字段失效的问题
    Chrome 调试技巧: 调整网速
    html2canvas导出图片模糊
    点击其他区域不让编辑器失去焦点
    启动的项目经常挂怎么办
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/3832920.html
Copyright © 2011-2022 走看看