zoukankan      html  css  js  c++  java
  • 动画反转与重复

     动画的反转

    执行与否与放置的位置有关。
    若放在动画对象动画动作之前,则执行,否则不执行。
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:2];
        [UIView setAnimationRepeatAutoreverses:YES];
        [UIView setAnimationRepeatCount:2];
        imageView.frame = CGRectMake(170, 300, 60, 50);   //执行返回一次,然后再回到动画结束的位置,即 (170, 300, 60, 50)
        [UIView commitAnimations];

    若将这两句的位置调换,即

    imageView.frame = CGRectMake(170, 300, 60, 50);
    [UIView setAnimationRepeatCount:2];
    [UIView setAnimationRepeatAutoreverses:YES];  //不执行反转

    动画的重复要与反转在一起搭配使用才能呈现效果

    [UIView setAnimationRepeatCount:2];  //设置动画重复次数要与反转放在一起,否则也不起作用
    [UIView setAnimationRepeatAutoreverses:YES];
    imageView.frame = CGRectMake(170, 300, 60, 50);

    如果分开放,只会反转一次(默认为一次)。

    [UIView setAnimationRepeatAutoreverses:YES];
    imageView.frame = CGRectMake(170, 300, 60, 50);
    [UIView setAnimationRepeatCount:2];  //只反转一次
  • 相关阅读:
    第01组 团队Git现场编程实战
    第01组 团队项目-需求分析报告
    团队项目-选题报告
    第二次结对编程作业
    第1组 团队展示
    第一次结对编程作业
    第一次博客作业
    2019 SDN上机第1次作业
    第08组 团队项目-需求分析报告
    团队项目-选题报告
  • 原文地址:https://www.cnblogs.com/hyhl23/p/4167953.html
Copyright © 2011-2022 走看看