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) {
                        
                    }];
                }];
            }];
        }];

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

  • 相关阅读:
    改善用户体验之alert提示效果
    用javascript制作放大镜放大图片
    window.history.go(1)返回上页的同时刷新"上页"技术
    JS折叠菜单
    懒得勤快的博客 resharper 等好文
    IBM DOMINO LOTUS LIMITS
    为CKEditor开发FLV视频播放插件
    Calling DLL routines from LotusScript. Part I: Windows API
    lotus domino下使用FCKeditor
    domino文件拆离数据库,放入指定目录
  • 原文地址:https://www.cnblogs.com/sixindev/p/4810579.html
Copyright © 2011-2022 走看看