zoukankan      html  css  js  c++  java
  • iOS layer 动画

    x轴缩放:
    CABasicAnimation *theAnimation;
    theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale.x"];
    theAnimation.duration=8;
    theAnimation.removedOnCompletion = YES;
    theAnimation.fromValue = [NSNumber numberWithFloat:1];
    theAnimation.toValue = [NSNumber numberWithFloat:0.5];
     [yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

    y轴缩放:
    CABasicAnimation *theAnimation;
    theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale.y"];
    theAnimation.duration=8;
    theAnimation.removedOnCompletion = YES;
    theAnimation.fromValue = [NSNumber numberWithFloat:1];
    theAnimation.toValue = [NSNumber numberWithFloat:0.5];
     [yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

    x轴,y轴同时按比例缩放:
    CABasicAnimation *theAnimation;
    theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];
    theAnimation.duration=8;
    theAnimation.removedOnCompletion = YES;
    theAnimation.fromValue = [NSNumber numberWithFloat:1];
    theAnimation.toValue = [NSNumber numberWithFloat:0.5];
     [yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

    以上缩放是以view的中心点为中心缩放的,如果需要自定义缩放点,可以设置卯点:
    //中心点
    [yourView.layer setAnchorPoint:CGPointMake(0.5, 0.5)];

    //左上角
    [yourView.layer setAnchorPoint:CGPointMake(0, 0)];

    //右下角
    [yourView.layer setAnchorPoint:CGPointMake(1, 1)];

  • 相关阅读:
    模板——二分法
    Trie Tree(静态数组写法,好写)
    欧拉路径 基础题 hiho第49周
    Fleury算法求欧拉路径 hiho第50周
    hdu 5266 pog loves szh III 在线lca+线段树区间优化
    hdu 5269 字典树
    hdu 5265 pog loves szh II
    poj 3678 2-sat(强连通)
    lca 在线,离线 poj 1330
    lca 在线算法 zoj 3195
  • 原文地址:https://www.cnblogs.com/XXxiaotaiyang/p/5043327.html
Copyright © 2011-2022 走看看