iOS 动画 UIView动画

//
//  ViewController.m
//  UI_23_动画
//
//  
//  Copyright © 2015年 lirui. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()


@property (strong, nonatomic) IBOutlet UIView *opeView1;

@property (strong, nonatomic) IBOutlet UIView *opeView2;





@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

}
#pragma mark 开始动画按钮
- (IBAction)startAnimationButtonDidClicked:(id)sender {
    
    #pragma mark 动画一
    
    
    //开始动画
    [UIView beginAnimations:nil context:nil];
    
    //动画时间
    [UIView setAnimationDuration:3.0f];
    //重复次数
    [UIView setAnimationRepeatCount:5];
    //设置UIView 动画自动翻转(返回动画)
    [UIView setAnimationRepeatAutoreverses:YES];
    
    //过渡效果
    self.opeView1.backgroundColor = [UIColor blackColor];
    self.opeView1.frame = CGRectMake(200, 500, self.opeView1.frame.size.width, self.opeView1.frame.size.height);
    self.opeView1.center = CGPointMake(200, 590);
    
    //提交动画
    [UIView commitAnimations];
    
    
    #pragma mark UIView 动画二  block形式
    
    [UIView animateWithDuration:3 animations:^{
        [UIView setAnimationRepeatCount:3];
        [UIView setAnimationRepeatAutoreverses:YES];
        self.opeView1.center = CGPointMake(280, 580);
        self.opeView2.center = CGPointMake(60, 580);
        
        self.opeView1.transform = CGAffineTransformRotate(self.opeView1.transform, M_2_PI);
        
        self.opeView1.transform = CGAffineTransformScale(self.opeView1.transform, 2, 2);
    }];
    
    
    #pragma mark 动画三:block里面可以嵌套 动画
    
    [UIView animateWithDuration:3 animations:^{
        
        //设置动画的速度曲线
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        
        
        self.opeView1.center = CGPointMake(280, 580);
    } completion:^(BOOL finished) {
        
        [UIView animateWithDuration:3 animations:^{
              self.opeView1.center = CGPointMake(90, 100);
        }];
      
    }];

    
   #pragma mark  动画四
    
    [UIView beginAnimations:nil context:nil];
    //设置动画代理
    [UIView setAnimationDelegate:self];
    //指定动画开始的方法
    [UIView setAnimationWillStartSelector:@selector(opeView1StartAnimating)];
    //指定动画结束的方法
    [UIView setAnimationDidStopSelector:@selector(opeView1DidStopAnimating)];
    
    //设置动画时间
    [UIView setAnimationDuration:3];
    self.opeView1.backgroundColor = [UIColor yellowColor];

    
    [UIView commitAnimations];
    
   #pragma mark 动画五
    [UIView transitionFromView:self.opeView1 toView:self.opeView2 duration:3 options:UIViewAnimationOptionTransitionFlipFromLeft completion:nil];
    
    
    
    
    
//    以上5种类型动画都属于UIView动画,都能真正改变UIView的属性
    

}

-(void)opeView1StartAnimating{
    
}

-(void)opeView1DidStopAnimating{
    
}





- (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、付费专栏及课程。

余额充值