我添加了一个阴影层作为 UIView 层的子层。以下是UIView
子类的添加方法:
- (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];
}
我想将其保留为UIView
使用 shadowSubview 调整动画大小的一部分。但是在使用时找不到正确的方法+ (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];
}];
请帮助我了解正确的方法。试图了解CABasicAnimation
,但找不到将其应用于此案例的方法。