I added a shadow layer as a sublayer to UIView's layer. Following is an added method for UIView
subclass:
- (void)addDefaultShadowSubview {
self.shadowSubview = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.frame.size.width, self.frame.size.height)] autorelease];
CALayer *shadowLayer = [CALayer layer];
shadowLayer.backgroundColor = self.backgroundColor.CGColor;
shadowLayer.shadowOffset = CGSizeMake(0, 3);
shadowLayer.shadowRadius = 5.0;
shadowLayer.shadowColor = [UIColor blackColor].CGColor;
shadowLayer.shadowOpacity = 0.8;
shadowLayer.frame = self.shadowSubview.frame;
[self.shadowSubview.layer addSublayer:shadowLayer];
self.shadowSubview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:self.shadowSubview];
[self sendSubviewToBack:self.shadowSubview];
}
I would like to keep it as a part of resizing animation of the an UIView
with shadowSubview. But can't find the right way to do it while using + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;
[UIView animateWithDuration:durationDefaultAnimation
animations:^{
[self.viewWithShadowSubview setFrame:enlargedFrame];
}
completion:^(BOOL finished) {
[self modifyInsetForCurrentImageviewWithAnimation:YES];
}];
Please help me to know to right way. Tried to learn about CABasicAnimation
, but can't find the way to apply it to this case.