码迷,mamicode.com
首页 > 其他好文 > 详细

2016-1-10 核心动画 图标抖动

时间:2016-01-11 18:17:08      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

//
//  ViewController.m
//  图标抖动
//
//  Created by Mac on 16/1/11.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
   
    
}
- (IBAction)startAnimation {
    CAKeyframeAnimation *rotationAni = [CAKeyframeAnimation animation];
    rotationAni.keyPath = @"transform.rotation";
    // 计算旋转的弧度
    CGFloat angle = M_PI_4 * 0.1;
    // 设置旋转的路径
    rotationAni.values = @[@(-angle),@(angle),@(-angle)];
    rotationAni.duration = 0.2;
    
    rotationAni.repeatCount = MAXFLOAT;
    [self.imageView.layer addAnimation:rotationAni forKey:@"shake"];
    }
- (IBAction)endAnimation {
    // 通过key 移除动画
    [self.imageView.layer removeAnimationForKey:@"shake"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

技术分享

2016-1-10 核心动画 图标抖动

标签:

原文地址:http://www.cnblogs.com/BJTUzhengli/p/5121881.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!