动画,(UIView上)
来源:互联网 发布:清理上网痕迹软件 编辑:程序博客网 时间:2024/05/22 04:28
//UIView动画 //开始动画 [UIView beginAnimations:nil context:nil]; //运动的时间 [UIView setAnimationDuration:2.0f]; //延时启动 //[UIView setAnimationDelay:2.f]; //速度曲线 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; //重复执行 [UIView setAnimationRepeatAutoreverses:YES]; //重复执行次数 [UIView setAnimationRepeatCount:10]; //代理 [UIView setAnimationDelegate:self]; //开始时候执行 [UIView setAnimationWillStartSelector:@selector(start)]; //结束的时候执行 [UIView setAnimationDidStopSelector:@selector(stop)]; //动画过程 //换背景色 self.myView.backgroundColor=[UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1]; //改位置 CGRect myFrame=self.myView.frame; //全局变量 static BOOL a =YES; if (a) { myFrame.origin.y+=100; myFrame.size.width+=50; a=NO; } else{ myFrame.origin.y-=100; myFrame.size.width-=50; a=YES; } self.myView.frame=myFrame; //改变透明度 //self.myView.alpha=0.1; //提交动画 [UIView commitAnimations];
block块执行
第一种
//系统自带的block块 [UIView animateWithDuration:2.0f animations:^{ self.myView.backgroundColor=[UIColor purpleColor]; }];第二种
/第一个block块执行了动画, //第二个block块是在执行完动画后执行的 [UIView animateWithDuration:2.f animations:^{ self.myView.backgroundColor=[UIColor greenColor]; } completion:^(BOOL finished) { self.myView.backgroundColor=[UIColor redColor]; }];
第三种
[UIView transitionWithView:self.myView duration:2.f options:UIViewAnimationOptionTransitionFlipFromRight animations:^{ NSLog(@"动画开始"); } completion:^(BOOL finished) { NSLog(@"动画结束"); }];
旋转
[UIView animateWithDuration:2.0f animations:^{// self.myView.transform=CGAffineTransformScale(self.myView.transform, 0.5f, 0.5f); self.myView.transform=CGAffineTransformRotate(self.myView.transform, M_PI_4); }];
0 0
- 动画,(UIView上)
- [iOS]UIView动画学习笔记(上)
- UIView动画
- UIView 动画
- UIView动画
- uiview动画
- UIView动画
- UIView 动画
- UIView动画
- 动画 UIView
- UIView动画
- UIView动画
- uiview 动画
- UIView 动画
- UIView动画
- UIView动画
- UIView动画
- UIView 动画
- java程序---将一个浮点数转换成人民币读法
- 类与方法
- NSDate、NSString、long转化
- java源码——两种格式日期的转换
- 错失良机了时的叫声的结论是电脑技术电脑技术
- 动画,(UIView上)
- poj 2236 Wireless Network 之幷查集
- Redis入门学习
- 怎样设计网站的技巧。网站的创意.
- Fill
- socket之异步connect
- Struts2注解开发之Configuration by Convention(一)
- 解决 CentOS 7.0 在VMware 10下安装 WMware Tools错误的问题
- UICollectionView的多边形布局-蜂窝布局