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];  //只反转一次
  • 相关阅读:
    问题 A: C#抽象类Vehicles
    最短路练习
    BFS
    poj 1083 Moving Tables
    组合数
    hdu 1443 Joseph【约瑟夫环】
    poj 2449 Remmarguts' Date【第K短路】
    hdu 1695 GCD 【莫比乌斯函数】
    hdu 2178 猜数字
    bzoj 2440 完全平方数 【莫比乌斯函数】
  • 原文地址:https://www.cnblogs.com/hyhl23/p/4167953.html
Copyright © 2011-2022 走看看