//動畫
// ViewController.mspa
// UIView動畫封裝-彈簧.net
//3d
// Created by dc008 on 15/12/22.orm
// Copyright © 2015年 崔曉宇. All rights reserved.ci
//get
#import "ViewController.h"animation
@interface ViewController ()it
{io
UIImageView *_imageView;
}
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ball"]];
_imageView.center = CGPointMake(375/2.0, 667/2.0);
[self.view addSubview:_imageView];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self.view];
//建立彈性動畫
//阻尼:返回0-1,越接近0,彈性效果越明顯
//velocity:彈性復原速度
//
[UIView animateWithDuration:5.0 delay:0 usingSpringWithDamping:0.1 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveLinear animations:^{
_imageView.center = location;//最終小球位置
} completion:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}