Я хочу нарисовать плавную анимацию в iOS, используя CAPropertyAnimations

Я хочу, чтобы анимация показывалась вот так

это работает так

Я хочу показать круговую анимацию. он становится больше постепенно. Я не хочу менять его положение.

мой код выглядит следующим образом, и положение круга также перемещается, как с этим справиться.

- (void)viewDidLoad
{
[super viewDidLoad];
int radius = 20;
CGPoint drawPoint = CGPointMake(self.view.frame.size.width/2 -radius,self.view.frame.size.height/2+radius*2);
CAShapeLayer *circle = [CAShapeLayer layer];
// Make a circular shape
circle.path = [UIBezierPath bezierPathWithArcCenter:drawPoint radius:radius startAngle:0 endAngle:M_PI*2 clockwise:NO].CGPath;
// Configure the apperence of the circle
UIColor *pointColor =[UIColor alloc];
pointColor = [UIColor redColor];
circle.fillColor = pointColor.CGColor;
circle.strokeColor = pointColor.CGColor;
circle.lineWidth = 1;
// Add to parent layer
[self.view.layer addSublayer:circle];
// Configure animation
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
// Set the initial and the final values
[pathAnimation setFromValue:[NSNumber numberWithFloat:0.5f]];
[pathAnimation setToValue:[NSNumber numberWithFloat:1.5f]];
[pathAnimation setDuration:1.0f];
[pathAnimation setRepeatCount:1.0f];
[pathAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[circle addAnimation:pathAnimation forKey:@"changePathAnimation"];    //--draw circle

}


person bohan    schedule 22.10.2013    source источник
comment
Это не связано, но почему вы выделяете здесь цветной объект???   -  person Tarun    schedule 22.12.2014


Ответы (1)


Ваша анимация относится к точке регистрации вашего CAShapeLayer, которая равна (0, 0) в координатах экрана.

Попробуй это:

circle.path = [UIBezierPath bezierPathWithArcCenter:CGPointZero radius:radius startAngle:0 endAngle:M_PI*2 clockwise:NO].CGPath;
circle.position = drawPoint;
person Yuriy Panfyorov    schedule 22.10.2013