IOS开发:动画1
来源:互联网 发布:代刷网 授权平台源码 编辑:程序博客网 时间:2024/05/16 07:03
#import "ViewController.h"@interface ViewController ()@property (weak, nonatomic) IBOutlet UIView *currentView;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.}/*语法形式: [UIView beginAnimations:@“动画的名字 “ context:nil]; …….. [UIView commitAnimations]; *///首尾动画- (IBAction)beginAndEndAnmation:(UIButton *)sender { [UIView beginAnimations:@"第一个动画" context:nil]; //是否根据最新的状态开始动画 [UIView setAnimationBeginsFromCurrentState:YES]; //设置延迟几秒开始动画// [UIView setAnimationDelay:1.0]; //动画执行时间 [UIView setAnimationDuration:2.0]; //设置动画翻转 [UIView setAnimationRepeatAutoreverses:YES]; //设置翻转次数 [UIView setAnimationRepeatCount:2]; //要执行动画开始和结束方法,一定要设置代理 [UIView setAnimationDelegate:self]; //动画结束执行方法 [UIView setAnimationDidStopSelector:@selector(endAction)]; //动画开始执行方法 [UIView setAnimationWillStartSelector:@selector(startAction)]; //拿到view的中心点 CGPoint point = self.currentView.center; //让view向下移动50 point.y += 50; self.currentView.center = point; //旋转 self.currentView.transform = CGAffineTransformRotate(self.currentView.transform, M_PI); //放缩 self.currentView.transform = CGAffineTransformScale(self.currentView.transform, 0.5, 0.5); [UIView commitAnimations]; }//结束时执行-(void)endAction{ NSLog(@"end");}//开始时执行-(void)startAction{ NSLog(@"start");}//block动画块- (IBAction)blockAnimation:(UIButton *)sender { //block动画1// [UIView animateWithDuration:2.0f animations:^{// //拿到view的中心点// CGPoint point = self.currentView.center;// // //让view向下移动50// point.y += 50;// self.currentView.center = point;//// }]; //block动画2// [UIView animateWithDuration:2.0f animations:^{// //拿到view的中心点// CGPoint point = self.currentView.center;// // //让view向下移动50// point.y += 50;// self.currentView.center = point;// } completion:^(BOOL finished) {// [UIView animateWithDuration:2.0f animations:^{// //拿到view的中心点// CGPoint point = self.currentView.center;//// //让view向下移动50// point.y -= 50;// self.currentView.center = point;//// }];// }]; //block动画3// [UIView animateKeyframesWithDuration:2.0f delay:1.0f options:UIViewKeyframeAnimationOptionRepeat animations:^{// //拿到view的中心点// CGPoint point = self.currentView.center;//// //让view向下移动50// point.y -= 50;// self.currentView.center = point;// // } completion:^(BOOL finished) {// NSLog(@"123");// }]; //第一个参数 弹簧动画效果(0-1) //第四个参数 动画起始速度 [UIView animateWithDuration:2.0f delay:1.0f usingSpringWithDamping:0.01 initialSpringVelocity:5.0f options:UIViewAnimationOptionRepeat animations:^{ //拿到view的中心点 CGPoint point = self.currentView.center; //让view向下移动50 point.y += 50; self.currentView.center = point; } completion:^(BOOL finished) { }]; }//转场动画- (IBAction)translationAnimation:(UIButton *)sender { // [UIView transitionWithView:self.currentView duration:3 options:UIViewAnimationOptionRepeat animations:^{// //拿到view的中心点// CGPoint point = self.currentView.center;// // //让view向下移动50// point.y += 50;// self.currentView.center = point;//// } completion:^(BOOL finished) {// // }]; UIView * view = [[UIView alloc]init]; view.backgroundColor = [UIColor yellowColor]; view.frame = CGRectMake(0, 0, 100, 100); [self.view addSubview:view]; //转场后 self.currentView 从父视图移除 toView显示 [UIView transitionFromView:self.currentView toView:view duration:2.0f options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) { }]; }- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
0 0
- IOS开发:动画1
- 动画-IOS开发
- 动画-IOS开发
- 【iOS开发】---- UIView动画
- 【iOS开发】---- UIView动画
- 动画-IOS开发
- 动画-IOS开发
- iOS 开发 动画总结
- ios 开发 ---动画
- IOS开发 开机动画
- 动画-IOS开发
- 浅谈ios开发---动画
- 动画-IOS开发
- iOS开发 动画 UIDynamicAnimator
- iOS开发--抛物线动画
- iOS开发 动画效果
- iOS开发系列--动画
- iOS开发 UI--动画
- SLIC超像素(superpixel)算法
- 标点符号的英语名称
- C# 对象比较(值类型、引用类型)
- Fragment和Actiity的交互关系讲解(整理别人的)
- SLIC超像素生成算法
- IOS开发:动画1
- SPFA算法模板
- isfinite() isinf() isnan() isnormal()
- imalse:DDOS攻击仿真
- 代码整洁之道学习(一)
- textview的drawablle属性
- EditText中 InputType
- SSD算法 模板 匹配
- QT多线程中的互斥与同步