Ответ 1
Там немного больше кода, чем можно было бы надеяться, но что-то вроде этого должно работать.
CGFloat animationDuration = 5.0;
// Create the CABasicAnimation for the shadow
CABasicAnimation *shadowAnimation = [CABasicAnimation animationWithKeyPath:@"shadowPath"];
shadowAnimation.duration = animationDuration;
shadowAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; // Match the easing of the UIView block animation
shadowAnimation.fromValue = (id)self.shadowedView.layer.shadowPath;
// Animate the frame change on the view
[UIView animateWithDuration:animationDuration
delay:0.0f
options:UIViewAnimationCurveEaseInOut
animations:^{
self.shadowedView.frame = CGRectMake(self.shadowedView.frame.origin.x,
self.shadowedView.frame.origin.y,
self.shadowedView.frame.size.width * 2.,
self.shadowedView.frame.size.height * 2);
} completion:nil];
// Set the toValue for the animation to the new frame of the view
shadowAnimation.toValue = (id)[UIBezierPath bezierPathWithRect:self.shadowedView.bounds].CGPath;
// Add the shadow path animation
[self.shadowedView.layer addAnimation:shadowAnimation forKey:@"shadowPath"];
// Set the new shadow path
self.shadowedView.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.shadowedView.bounds].CGPath;