您的位置:首页 > 产品设计 > UI/UE

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之前,用户交互是整个应用程序被禁用)

上代码:

#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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iOS UIView 动画 变更