zoukankan      html  css  js  c++  java
  • ios22--动画

    控制器:

    //
    //  ViewController.m
    //  07-渐变动画
    //
    //  Created by xiaomage on 15/12/30.
    //  Copyright © 2015年 小码哥. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @interface ViewController ()
    @property (weak, nonatomic) IBOutlet UIView *animationView;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    }
    
    /**
     *  平移
     */
    - (IBAction)translate {
        // 渐变动画
        // 方式一
        /*
        // 1. 开始动画
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:1.0];
        
        // 2.动画代码
        CGRect frame = self.animationView.frame;
        frame.origin.y -= 50;
        self.animationView.frame = frame;
        
        // 3.提交动画
        [UIView commitAnimations];
         */
        
        // 方式二:
        /*
        [UIView animateWithDuration:2.0 animations:^{
            // 1.动画代码
            CGRect frame = self.animationView.frame;
            frame.origin.y -= 50;
            self.animationView.frame = frame;
        }];
         */
        
        /*
        [UIView animateWithDuration:1.0 animations:^{
            // 执行动画
            CGRect frame = self.animationView.frame;
            frame.origin.y -= 50;
            self.animationView.frame = frame;
        } completion:^(BOOL finished) {
           // 动画完成做什么事情
            self.animationView.backgroundColor = [UIColor blackColor];
        }];
         */
        /*
         UIViewAnimationOptionCurveEaseInOut  动画开始/结束比较缓慢,中间相对较快
         UIViewAnimationOptionCurveEaseIn     动画开始比较缓慢
         UIViewAnimationOptionCurveEaseOut    动画结束比较缓慢
         UIViewAnimationOptionCurveLinear     线性---> 匀速
         */
        [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
            
            CGRect frame = self.animationView.frame;
            frame.origin.y += 50;
            self.animationView.frame = frame;
            
        } completion:^(BOOL finished) {
            self.animationView.backgroundColor = [UIColor greenColor];
        }];
    }
    
    /**
     *  缩放
     */
    - (IBAction)scale {
        
        [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
            
            CGRect frame = self.animationView.frame;
            frame.size = CGSizeMake(10, 15);
            self.animationView.frame = frame;
            
        } completion:^(BOOL finished) {
            NSLog(@"动画完成");
        }];
    }
    
    /**
     *  透明度动画
     */
    - (IBAction)alpha {
        [UIView animateWithDuration:1.0 delay:0.5 options:UIViewAnimationOptionCurveEaseOut animations:^{
            self.animationView.alpha -= 0.9;
        } completion:^(BOOL finished) {
           [UIView animateWithDuration:2.0 animations:^{
               self.animationView.alpha += 0.9;
           }];
        }];
    }
    @end
  • 相关阅读:
    疑似CPU或者内存故障导致进程崩溃
    free如何知道释放内存长度:vs与glibc分配内存时编译器内部处理
    stun简介
    H264(NAL简介与I帧判断)
    H264码率设置
    简单的makefile模板
    ffmpeg显示视频
    一些yuv视频下载地址
    转载:P2P技术原理及应用(2)
    转载:P2P技术原理及应用(1)
  • 原文地址:https://www.cnblogs.com/yaowen/p/7469583.html
Copyright © 2011-2022 走看看