zoukankan      html  css  js  c++  java
  • 按下和弹起效果的按钮分类(POP实现)

    使用POP实现按下/弹起效果的按钮分类。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    //
    //  UIButton+SpringTouch.h
    //  JCiOSProjectSample
    //
    //  Created by jimple on 14/7/28.
    //  Copyright (c) 2014年 JimpleChen. All rights reserved.
    //
     
    #import <UIKit/UIKit.h>
     
    @interface UIButton (SpringTouch)
     
    - (void)initSpringTouch;
    - (void)removeSpringTouch;
     
    @end
     
    ////////////////////////////////////////////////////////////////////////////
     
    //
    //  UIButton+SpringTouch.m
    //  JCiOSProjectSample
    //
    //  Created by jimple on 14/7/28.
    //  Copyright (c) 2014年 JimpleChen. All rights reserved.
    //
     
    #import "UIButton+SpringTouch.h"
    #import <POP.h>
     
    @implementation UIButton (SpringTouch)
     
     
    - (void)initSpringTouch
    {
        [self addTarget:self action:@selector(springTouchBtnTouchDown:) forControlEvents:UIControlEventTouchDown];
        [self addTarget:self action:@selector(springTouchBtnTouchUp:) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
    }
     
    - (void)removeSpringTouch
    {
        [self removeTarget:self action:@selector(springTouchBtnTouchDown:) forControlEvents:UIControlEventTouchDown];
        [self removeTarget:self action:@selector(springTouchBtnTouchUp:) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
    }
     
    - (void)springTouchBtnTouchDown:(id)sender
    {
        UIView *btn = (UIView *)sender;
        POPSpringAnimation *animation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
         
        animation.toValue = [NSValue valueWithCGPoint:CGPointMake(0.9, 0.9)];
        animation.springBounciness = 10;
        [btn.layer pop_addAnimation:animation forKey:@"ZoomOutY"];
    }
     
    - (void)springTouchBtnTouchUp:(id)sender
    {
        UIView *btn = (UIView *)sender;
         
        [btn.layer pop_removeAnimationForKey:@"ZoomOutY"];
         
        POPSpringAnimation *animation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
        animation.toValue = [NSValue valueWithCGPoint:CGPointMake(1, 1)];
        animation.springBounciness = 10;
         
        [btn.layer pop_addAnimation:animation forKey:@"ZoomOutYReverse"];
    }
     
     
    @end
     
  • 相关阅读:
    Visual Studio Installer打包安装项目VS2015
    在WinCE上播放声音、设置透明图片、系统音量 C#
    虚函数、抽象函数以及接口的区别
    Type 'System.IO.FileStream' with data contract name 'FileStream:http://schemas.datacontract.org/2004/07/System.IO' is not expected.
    项目中重新引用WCF报错
    为什么0.1+0.2=0.30000000000000004
    MVC自定义错误页404静态页
    DP 网易内推:合唱团
    TFBOY 养成记 一些比较好多文章。
    机器学习笔记:为什么要对数据进行归一化处理?
  • 原文地址:https://www.cnblogs.com/ranger-jlu/p/3884236.html
Copyright © 2011-2022 走看看