zoukankan      html  css  js  c++  java
  • iphone中CABasicAnimation和UIView动画的区别[转]

    关于UIView动画:

    1. [UIView beginAnimations:@"zoom out" context:nil];
    2. [UIView setAnimationDuration:1.f];
    3. [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    4. cover.transform = CGAffineTransformMakeScale(9.25,7.05);
    5. cover.center = CGPointMake(430512);
    6. [UIView commitAnimations]

    UIView动画是应用在一个view上面的。

    关于CABasicAnimation动画:

    1. - (CAAnimation *)animationMove:(CGPoint)rootCenter
    2. {
    3.     CABasicAnimation *animationMove
    4.     = [CABasicAnimation animationWithKeyPath:@"position"];
    5.     animationMove.duration = 1;
    6.     animationMove.autoreverses = NO;
    7. //    animationMove.delegate = self;
    8.     animationMove.removedOnCompletion = NO;
    9.     animationMove.fillMode = kCAFillModeForwards;
    10.     animationMove.fromValue = [NSValue valueWithCGPoint:self.oldCoverCenter];
    11.     animationMove.toValue =[NSValue valueWithCGPoint:rootCenter];
    12.  
    13.     return animationMove;
    14. }

    CABasicAnimation动画是应用在一个layer上面的。

    注:
    1,把一个image放在一个view的layer上来放大的时候,如果用UIView来做,图片不会太多的失真和闪烁的效果,但是用CABasicAnimation来做失真和闪烁现象会很严重,效果很不好。
    2,做 动画的叠加效果 很简单,只要把各自的动画放在一起就可以了。请看这个效果:一本书边移动到屏幕中间,边放大,边打开封面的效果。

    1. [imageLayer addAnimation:[self animationOpen] forKey:@"Open"];
    2. [UIView beginAnimations:@"zoom out" context:nil];
    3. [UIView setAnimationDuration:1.f];
    4. [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    5. cover.transform = CGAffineTransformMakeScale(5.5,5.5);
    6. cover.center = CGPointMake(629384);
    7. [UIView commitAnimations];
    8.  
    9. - (CAAnimation *)animationOpen
    10. {
    11.     CABasicAnimation *animationOpen
    12.     = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
    13.     animationOpen.duration = 1;
    14.     animationOpen.autoreverses = NO;
    15.     animationOpen.delegate = self;  //然后执行真正地打开书的内容
    16.     animationOpen.removedOnCompletion = NO;
    17.     animationOpen.fillMode = kCAFillModeForwards;
    18.     animationOpen.fromValue = [NSNumber numberWithFloat:-M_PI/5];
    19.     animationOpen.toValue = [NSNumber numberWithFloat:-M_PI/1.5];
    20.  
    21.     return animationOpen;
    22. }
  • 相关阅读:
    HDU6393(LCA + RMQ + 树状数组) n边图,两点最短距离 , 修改边权
    POJ 2763 (LCA +RMQ+树状数组 || 树链部分) 查询两点距离+修改边权
    HDU6396 (贪心+fread 挂)
    使用hadoop自带的例子作测试 笔记三
    hadoop的布暑方式 笔记二
    1 Hadoop原理介绍 笔记一
    ssh+flex
    openssh升级过程
    redhat5yum源配置
    struts2实现权限拦截
  • 原文地址:https://www.cnblogs.com/bandy/p/2418358.html
Copyright © 2011-2022 走看看