CABasicAnimation - transform scale keep in center

前端 未结 4 1286
南笙
南笙 2021-02-07 02:27

Trying to animatie an ellipse masked on a UIView to be scale transformed remaining in the center position.

I have found CALayer - CABasicAnimation not scaling around cen

4条回答
  •  既然无缘
    2021-02-07 03:01

    I seem to have fixed this with a second animation on the position key. Is this correct or is there a better way of doing this?

    CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"position"];
    
    animation2.duration = 1.0f;
    
    animation2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    
    animation2.fromValue = [NSValue valueWithCGPoint:CGPointMake((self.view.frame.size.width/2), (self.view.frame.size.height/2))];
    animation2.toValue = [NSValue valueWithCGPoint:CGPointMake((self.view.frame.size.width/2), (self.view.frame.size.height/2))];
    
    [toBeMask.layer.mask addAnimation:animation2 forKey:@"animateMask2"];
    

提交回复
热议问题