【问题标题】:CALayer scale animation for layer size starting from bottom left to top right从左下角到右上角的图层大小的 CALayer 缩放动画
【发布时间】:2012-03-23 10:12:40
【问题描述】:

图层上的动画的另一个问题是使其缩放并显示为从左下角开始增长,有点类似于图:

---------------    
|             |
|----------   |
|         |   |
|         |   |
|-----    |   |
|    |    |   |
---------------

我尝试了一些动画,但无法完全按照我想要的方式实现。 请建议。目前使用以下代码进行缩放:

layer.anchorPoint = CGPointMake(1, 1);
CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
[scale setFromValue:[NSNumber numberWithFloat:0.0f]];
[scale setToValue:[NSNumber numberWithFloat:1.0f]];
[scale setDuration:1.0f];
[scale setRemovedOnCompletion:NO];
[scale setFillMode:kCAFillModeForwards];

【问题讨论】:

  • 刚刚编辑了我的问题。

标签: ios ios5 ios4


【解决方案1】:

你应该设置一个不同的锚点来达到这个效果。

    layer.anchorPoint = CGPointMake(0.0f, 1.0f);

【讨论】:

    【解决方案2】:

    希望对你有帮助:

    let frame = pathView.frame
    let anchorPoint = CGPointMake(0, 1) //Set the animation direction
    let position = CGPointMake(frame.origin.x + anchorPoint.x * frame.size.width, frame.origin.y + anchorPoint.y * frame.size.height)
    pathView.layer.anchorPoint = anchorPoint
    pathView.layer.position = position
    UIView.animateWithDuration(0.8){ () -> Void in
        pathView.layer.transform = CATransform3DMakeScale(0.5, 0.5, 1)
    }
    

    【讨论】:

      【解决方案3】:

      所有这些对我都不起作用。 固定框架和点的方法

      - (CGRect) fixRect:(CGRect)rect inRect:(CGRect)container
      {
          CGRect frame = rect;
          frame.origin.y = container.size.height - frame.origin.y - frame.size.height;
          return frame;
      }
      - (CGPoint) fixPoint:(CGPoint)point fromPoint:(CGSize)containerSize
      {
          CGPoint frame = point;
          frame.y = size.height - frame.y;
          return frame;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-22
        • 1970-01-01
        • 2015-09-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多