UIView 之 Animation 一边上跳 一边旋转
2015-11-05 14:52
274 查看
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100,100,100,100)];
view.backgroundColor = [UIColor redColor];
[self.view addSubview:view];
上跳:
[UIView beginAnimations:@""context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.7f];
[UIView setAnimationRepeatCount:30];
CGPoint center = view.center;
if (center.y >40.f) {
center.y -=20;
view.center = center;
}else{
center.y +=20;
view.center = center;
}
[UIView commitAnimations];
旋转:
for(int i =0; i <100;
i++){
[UIView beginAnimations:@"rotate"context:nil];
[UIView setAnimationDuration:10];
view.transform=CGAffineTransformMakeRotation((i+1)*2.0*M_PI/11.0);
[UIView commitAnimations];
}
view.backgroundColor = [UIColor redColor];
[self.view addSubview:view];
上跳:
[UIView beginAnimations:@""context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.7f];
[UIView setAnimationRepeatCount:30];
CGPoint center = view.center;
if (center.y >40.f) {
center.y -=20;
view.center = center;
}else{
center.y +=20;
view.center = center;
}
[UIView commitAnimations];
旋转:
for(int i =0; i <100;
i++){
[UIView beginAnimations:@"rotate"context:nil];
[UIView setAnimationDuration:10];
view.transform=CGAffineTransformMakeRotation((i+1)*2.0*M_PI/11.0);
[UIView commitAnimations];
}
相关文章推荐
- OpenAL Tutorial - Playing WAV files (No ALUT required!)
- 简易入手SUI
- IOS动画中的枚举UIViewAnimationOptions
- LeetCode/Dynamic Programming/Unique Paths
- IOS UIScrollView
- hibernate 中createQuery与createSQLQuery的用法和区别
- 超简单的 BlueTooth 蓝牙开发实例,打开蓝牙,关闭蓝牙,配对,解除,功能齐全
- iOS开发- UICollectionView详解+实例
- UI设计要学哪些软件
- spark program guide
- hdoj House Building 5538 (数学几何&&搜索)
- [leetcode300] Longest Increasing Subsequence
- QT笔记:数据库总结(二)之SQL模型类-QSqlQueryModel模型
- IOS特定条件上UITABLEVIEWCELL不刷新的现象
- Leetcode: Longest Increasing Subsequence
- maven_Error building POM (may not be this project's POM)错误
- UITableView中没有数据时,让其不显示下划线的两种方法
- EasyUI - Tree 树组件
- EasyUI - ComboBox 下拉组件
- UILabel 自动换行 和支持换行符