iOS之UIView的变更动画
2015-08-05 20:36
507 查看
Quick Help:
Animate changes to one or more views using the specified duration.
This method performs the specified animations immediately using the UIViewAnimationOptionCurveEaseInOut and UIViewAnimationOptionTransitionNone animation options.
During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.)
翻译:在指定的时间内更改一个或多个视图的动画更改。
此方法执行指定的动画立即使用uiviewanimationoptioncurveeaseinout和uiviewanimationoptiontransitionnone动画选项。
在一个动画过程中,这些UIView的用户交互被暂时禁用(在iOS 5之前,用户交互是整个应用程序被禁用)
上代码:
Animate changes to one or more views using the specified duration.
This method performs the specified animations immediately using the UIViewAnimationOptionCurveEaseInOut and UIViewAnimationOptionTransitionNone animation options.
During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.)
翻译:在指定的时间内更改一个或多个视图的动画更改。
此方法执行指定的动画立即使用uiviewanimationoptioncurveeaseinout和uiviewanimationoptiontransitionnone动画选项。
在一个动画过程中,这些UIView的用户交互被暂时禁用(在iOS 5之前,用户交互是整个应用程序被禁用)
上代码:
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //创建一个UIView 控件 UIView *view=[[UIView alloc]initWithFrame:CGRectMake(10, 20, 100, 100)]; // 给UIView 添加一个颜色 view.backgroundColor=[UIColor greenColor]; // 把View 添加到视图上 [self.view addSubview:view]; // UIView 的简单动画,可以改变UIView 以及UIView 子类的坐标,大小,颜色,透明度的动画 view.alpha=1.0; //UIView的透明度属性,默认是1.0,当设置为0.0的时候透明度为0了,视图就不显示,值,0.0--1.0 // [UIView animateWithDuration:2.5 animations:^{ // 移动 view view.frame=CGRectMake(200, 100, 100, 100); view.alpha=0.4; view.backgroundColor=[UIColor redColor]; }]; // ================================ //创建一个UIView 控件 UIView *view1=[[UIView alloc]initWithFrame:CGRectMake(20, 120, 100, 100)]; // 添加一个背景颜色 view1.backgroundColor=[UIColor greenColor]; //添加到视图上面 [self.view addSubview:view1]; [UIView animateWithDuration:2.9 animations:^{ view1.frame=CGRectMake(200, 220, 100, 100); } completion:^(BOOL finished) { NSLog(@"我的动画执行完了"); }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- Gifski:一个跨平台的高质量 GIF 编码器
- 模仿动画的放大缩小容器
- php判断GIF图片是否为动画的方法
- 浅析JavaScript动画
- js排序动画模拟-插入排序
- jQuery动画特效实例教程
- JQuery动画和停止动画实例代码
- JQuery动画与特效实例分析
- shell脚本实现实时检测文件变更
- Jquery 自定义动画概述及示例
- 基于jquery的动画效果代码
- 锋利的jQuery 要点归纳(三) jQuery中的事件和动画(上:事件篇)
- 基于Jquery的温度计动画效果