iOS之UIView的变更动画

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值