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实现。

  • 相关阅读:
    大道至简——一个例子讲清楚观察者模式
    博客园界面代码风格自定义设置
    前端资源网址大集合
    如何检测浏览器是否安装了Adblock,uBlock Origin,Adguard,uBlock等广告屏蔽插件
    WebUploader 上传插件结合bootstrap的模态框使用时选择上传文件按钮无效问题的解决方法
    js中+号的另外一种用法
    C++ 最简单的日志类
    树莓派入门(3)—— 基本配置
    树莓派入门(2)——安装系统
    树莓派入门(1)——准备工作
  • 原文地址:https://www.cnblogs.com/so-magic/p/4616674.html
Copyright © 2011-2022 走看看