を使用CABasicAnimation
してboundsプロパティを変更し、それを使用してレイヤーのpositionプロパティを変更しています。両方を同時に行うことは可能ですか?UIView
?のフレームを変更するようなものです。
CGRect oldBounds = mask.bounds;
CGRect newBounds = CGRectMake(0,0, rect.size.width * scale, rect.size.height * scale);
NSLog(@"%@", NSStringFromCGRect(newBounds));
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"bounds"];
animation.fromValue = [NSValue valueWithCGRect:oldBounds];
animation.toValue = [NSValue valueWithCGRect:newBounds];
mask.bounds = newBounds;
[mask addAnimation:animation forKey:@"bounds"];
CGPoint oldPos = mask.position;
CGPoint newPos = CGPointMake(rect.origin.x * scale, rect.origin.y * scale);
CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"position"];
animation2.fromValue = [NSValue valueWithCGPoint:oldPos];
animation2.toValue = [NSValue valueWithCGPoint:newPos];
mask.position = newPos;
[mask addAnimation:animation2 forKey:@"position"];