OBjective-c 弹簧效果
2015-12-22 00:00
447 查看
ViewController.m文件
// // ViewController.m // 弹簧 // // Created by DC017 on 15/12/22. // Copyright © 2015年 DC017. All rights reserved. // #import "ViewController.h" @interface ViewController () { UIImageView * image; } @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; //创建图像 image=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ball"]]; image.frame=CGRectMake(375/2.0, 667/2, 50,50); [self.view addSubview:image]; } #pragma mark 点击事件 -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ UITouch *touch=[touches anyObject]; CGPoint XY=[touch locationInView:self.view]; //创建弹性动画 //damping阻尼 : 返回0-1,接近0,弹性效果越明显 //velocity:弹性复原速度 [UIView animateWithDuration:5.0 delay:0 usingSpringWithDamping:0.1 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveLinear animations:^{ image.center=XY;//最终小球的位置 } completion:nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
相关文章推荐
- objective-c 逐帧动画
- Object-C 一些关键字的理解 @synchronized、__block、class等。。。
- “object name conflicts in archive”的解决办法
- Mybatis3源码分析(12)-Sql解析执行-MetaObject
- 【Objective-C学习记录】第二十天
- Android中两个activity之间传递list<object>
- 关于Objective-C 错误代码 Expression is not assignable 引发的问题
- Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks程序(Python)配置问题总结
- Objective-c语言_协议
- Objective-c语言_延展
- Objective-c语言_类目
- dYSM分析崩溃日志
- #Objective - C - Fifth-Day 三大容器(数组、字典、集合)常用语法归纳总结
- JAVA 1.6源码解析-Object类
- The constness of a method should makes sense from outside the object
- Informatica Connection Objects
- Objective-c语言_文件基本操作
- Java基础系列六、IDE+Object+String
- 使用 SWFObject.js 插入Flash
- objective-c语言_data的转换