一天一工程总结系列-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.youkuaiyun.com/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实现。

转载于:https://www.cnblogs.com/so-magic/p/4616674.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值