【发布时间】:2013-11-11 19:16:12
【问题描述】:
我有一个圆圈,我用动画制作了它向外生长和变大的动画。不幸的是,尽管我设置了anchorPoint,但它并没有从中心向外动画,它似乎锁定了左上角的位置。怎么回事?
查看这张描绘偏离中心的圆圈的图片
代码
- (void)setLayerProperties {
rippleLayer = [[CAShapeLayer alloc] init];
rippleLayer.fillColor = [UIColor clearColor].CGColor;
rippleLayer.strokeColor = _Color.CGColor;
//rippleLayer.contentsGravity = @"center";
rippleLayer.anchorPoint = CGPointMake(0.5,0.5);
rippleLayer.bounds = self.bounds;
rippleLayer.path = bezierPath.CGPath;
[self.layer addSublayer:rippleLayer];
}
// Now animate the circle outwards
rippleLayer.opacity = 1;
CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
[scale setFromValue:[NSNumber numberWithFloat:1.0f]];
[scale setToValue:[NSNumber numberWithFloat:2.0f]];
[scale setRepeatCount:1];
[scale setDuration:1.0f];
//[scale setRemovedOnCompletion:YES];
[scale setFillMode:kCAFillModeForwards];
[rippleLayer addAnimation:scale forKey:scale.keyPath];
【问题讨论】:
-
@lionserdar 谢谢,我已经有了并且确实设定了我的界限——我还缺少什么吗?
标签: ios iphone objective-c uikit cabasicanimation