Hey,
I've got a UIView with a slight drop shadow using its layer's shadow properties. I set up the shadow as such:
I then make sure to set the shadowPath on the layer in order to improve performance.
I currently do this in the view's layoutSubviews method in order to catch an resizing I do after it's loaded from the nib. I adjust the position and size of this view in response to some user interaction and on rotation.
The issue I'm having is that by defining the shadowPath the shadow either doesn't change (if I remove setting the shadowPath in layoutSubviews) or it does not animate with the view's animation and simply "jumps" to the target size and location of the view.
I know that shadowPath supports explicit animations, but I'm not sure the right place to insert that animation. I've also tried creating a custom CALayer and use that as the view's layer class. Since I'm defining the shadowPath that doesn't solve the issue.
Any suggests on how to animate the position/size of a view's shadowPath?
I've got a UIView with a slight drop shadow using its layer's shadow properties. I set up the shadow as such:
Code:
- (void)awakeFromNib
{
[super awakeFromNib];
self.clipsToBounds = NO;
self.layer.masksToBounds = NO;
self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowOffset = CGSizeMake(0.f, 0.f);
self.layer.shadowOpacity = 0.6f;
self.layer.shadowRadius = 10.f;
...
}
I then make sure to set the shadowPath on the layer in order to improve performance.
Code:
- (void)layoutSubviews
{
self.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
...
}
I currently do this in the view's layoutSubviews method in order to catch an resizing I do after it's loaded from the nib. I adjust the position and size of this view in response to some user interaction and on rotation.
The issue I'm having is that by defining the shadowPath the shadow either doesn't change (if I remove setting the shadowPath in layoutSubviews) or it does not animate with the view's animation and simply "jumps" to the target size and location of the view.
I know that shadowPath supports explicit animations, but I'm not sure the right place to insert that animation. I've also tried creating a custom CALayer and use that as the view's layer class. Since I'm defining the shadowPath that doesn't solve the issue.
Any suggests on how to animate the position/size of a view's shadowPath?