zoukankan      html  css  js  c++  java
  • 自定义简单动画

    注释:

    duration 动画完成时间,
    delay 动画延长时间,可以理解为动画速度的时间控制

    一,利用

    CGAffineTransformMakeScale来做图形的缩放效果

    view.transform = CGAffineTransformMakeScale(1, 1);
        [UIView animateKeyframesWithDuration:duration/3 delay:delay options:0 animations:^{
            // End
            view.transform = CGAffineTransformMakeScale(1.2, 1.2);
        } completion:^(BOOL finished) {
            [UIView animateKeyframesWithDuration:duration/3 delay:0 options:0 animations:^{
                // End
                view.transform = CGAffineTransformMakeScale(0.9, 0.9);
            } completion:^(BOOL finished) {
                [UIView animateKeyframesWithDuration:duration/3 delay:0 options:0 animations:^{
                    // End
                    view.transform = CGAffineTransformMakeScale(1, 1);
                } completion:^(BOOL finished) {
                    
                }];
            }];
        }];

    二,结合alpha来做闪现缩放

    view.alpha = 1;
        view.transform = CGAffineTransformMakeScale(0.9, 0.9);
        
        [UIView animateKeyframesWithDuration:duration/3 delay:delay options:0 animations:^{
            // End
            view.alpha = 0;
            view.transform = CGAffineTransformMakeScale(1.2, 1.2);
        } completion:^(BOOL finished) {
            
        }];

     三,利用

    CGAffineTransformMakeTranslation来做view的移动动画

    view.transform = CGAffineTransformMakeTranslation(CGRectGetWidth([UIScreen mainScreen].bounds), 0);
        [UIView animateKeyframesWithDuration:duration/4 delay:delay options:0 animations:^{
            // End
            view.transform = CGAffineTransformMakeTranslation(-10, 0);
        } completion:^(BOOL finished) {
            [UIView animateKeyframesWithDuration:duration/4 delay:0 options:0 animations:^{
                // End
                view.transform = CGAffineTransformMakeTranslation(5, 0);
            } completion:^(BOOL finished) {
                [UIView animateKeyframesWithDuration:duration/4 delay:0 options:0 animations:^{
                    // End
                    view.transform = CGAffineTransformMakeTranslation(-2, 0);
                } completion:^(BOOL finished) {
                    [UIView animateKeyframesWithDuration:duration/4 delay:0 options:0 animations:^{
                        // End
                        view.transform = CGAffineTransformMakeTranslation(0, 0);
                    } completion:^(BOOL finished) {
                        
                    }];
                }];
            }];
        }];

    当然以上这些都是可以相互组合来做更炫酷的动画,具体只需要了解响应的原理,便可根据需要做出自定义的动画

  • 相关阅读:
    如何将SLIC集成到ESXi中
    System Board Replacement Notice
    分发器上的会话代理进程控制脚本使用说明
    lib和dll的区别与使用
    vs2017自动生成的#include“stdafx.h”详解及解决方案
    禅定是否一定要打坐,为什么?
    PE文件解析 基础篇
    灵修书籍
    HDU 2546 饭卡(01背包裸题)
    codeforces 767A Snacktower(模拟)
  • 原文地址:https://www.cnblogs.com/sixindev/p/4810579.html
Copyright © 2011-2022 走看看