Ios Cabasicanization从右上角开始,而不是从中间开始
我有一个圆圈,我把它画得越来越大。不幸的是,尽管我设置了Ios Cabasicanization从右上角开始,而不是从中间开始,ios,iphone,objective-c,uikit,cabasicanimation,Ios,Iphone,Objective C,Uikit,Cabasicanimation,我有一个圆圈,我把它画得越来越大。不幸的是,尽管我设置了anchorPoint它没有从中心向外设置动画,但它似乎锁定了左上角的位置。发生了什么事 请参见此图,该图描绘了偏离中心的圆 代码 若要在图层中心缩放图层,您需要设置图层的位置。这可能会对您有所帮助 定义弧度(角度)((角度)/180.0*M_-PI) 若要在图层中心缩放图层,您需要设置图层的位置。这可能会对您有所帮助 定义弧度(角度)((角度)/180.0*M_-PI) 检查此线程@lionserdar谢谢,我已经并确实设置了边界-
anchorPoint
它没有从中心向外设置动画,但它似乎锁定了左上角的位置。发生了什么事
请参见此图,该图描绘了偏离中心的圆
代码
若要在图层中心缩放图层,您需要设置图层的位置。这可能会对您有所帮助 定义弧度(角度)((角度)/180.0*M_-PI)
若要在图层中心缩放图层,您需要设置图层的位置。这可能会对您有所帮助 定义弧度(角度)((角度)/180.0*M_-PI)
检查此线程@lionserdar谢谢,我已经并确实设置了边界-我还缺少什么吗?检查此线程@lionserdar谢谢,我已经并确实设置了边界-我还缺少什么吗?
- (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];
CGPoint testCenter = CGPointMake(144.5, 230.0);
CAShapeLayer *aTestLayer = [CAShapeLayer layer];
aTestLayer.path = [UIBezierPath bezierPathWithArcCenter:**CGPointZero** radius:15.0 startAngle:RADIANS(0) endAngle:RADIANS(360) clockwise:YES].CGPath;
aTestLayer.fillColor = [UIColor clearColor].CGColor;
aTestLayer.strokeColor = [UIColor whiteColor].CGColor;
**aTestLayer.position = testCenter;**
aTestLayer.borderWidth = 2.0;
[self.view.layer addSublayer:aTestLayer];
CABasicAnimation *pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
pulse.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
pulse.duration = 2;
pulse.repeatCount = HUGE_VALF;
pulse.autoreverses = YES;
pulse.fromValue = [NSNumber numberWithFloat:1.0];
pulse.toValue = [NSNumber numberWithFloat:2.0];
[aTestLayer addAnimation:pulse forKey:nil];