zoukankan      html  css  js  c++  java
  • 一天一工程总结系列-7.2

    2015
    7.2
    一天一工程总结系列
    对各类优秀工程的剖析和拙见。有些胡言乱语还请作者谅解。

    VBFPopFlatButton
    1.执行多次的单例
    #define AGEColorImplement(COLOR_NAME,RED,GREEN,BLUE)   
    + (UIColor *)COLOR_NAME{   
        static UIColor* COLOR_NAME##_color;   
        static dispatch_once_t COLOR_NAME##_onceToken;  
        dispatch_once(&COLOR_NAME##_onceToken, ^{   
            COLOR_NAME##_color = [UIColor colorWithRed:RED green:GREEN blue:BLUE alpha:1.0]; 
            NSLog(@"1");
        });
        return COLOR_NAME##_color; 
    }

    有个牛人对dispatch_once的代码级解析:http://blog.csdn.net/uxyheaven/article/details/24735237

    这样的写法来自http://blog.alexedge.co.uk/speeding-up-uicolor-categories/

    2.VBFPopFlatButton

    继承自UIButton。

    VBFPopFlatButton有一个NSInteger类型的枚举FlatButtonType,对应Demo里的各种按钮样式。

    另外含有三个VBFDoubleSegment的实例变量,firstSegment,secondSegment,thirdSegment.

    关键函数

    -(void)animateToTyle:(FlatButtonType)finalTyle

    {

         [self.xxSegment moveToState:xxxx animated:self.animateToStartPosition];

        [self addSpringRotationToLayer:self.topLine toValue:toValueTop];

                       POPSpringAnimation anim.toValue = @(toValue);

        self.xxLine.transform = CATransform3DMakeRotation(toValueTop,,,);

         [self.xxSegment movePositionToPoint:xxxOriginPoint animated:self.animateToStartPosition];

                [self addSpringTranslationToLayer:self.topLine toValue:toPoint];

                        POPSpringAnimation anim.toValue = @(toValue);

                self.xxLine.position = finalPosition

    }

    3.@interface VBFDoubleSegment:CALayer

    有一个NSInteger类型的DoubleSegmentState枚举,每一个枚举对应一个按钮样式。

    包含两个成员,topLine/bottomLine,两者均是CAShapeLayer的实例变量。这两个layer,用addsubLayer的方式加在VBFDoubleSegment上。

    4.动画效果,由第三方类pop实现。

  • 相关阅读:
    2.16 C++类与new和delete操作符
    2.15 C++常量指针this
    2.14 C++析构函数
    2.13 C++拷贝构造函数
    2.12 C++ explicit关键字详解
    2.11 C++转型构造函数
    2.10 C++利用构造函数限制对象的创建
    2.9 C++使用默认参数的构造函数
    2.8 C++参数初始化表
    linux 查看进程启动路径
  • 原文地址:https://www.cnblogs.com/so-magic/p/4616674.html
Copyright © 2011-2022 走看看