【发布时间】:2012-03-03 16:32:32
【问题描述】:
我添加了一个阴影层作为 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,但找不到将其应用于此案例的方法。
【问题讨论】:
-
为什么不在shadowSubview层设置阴影?
标签: ios animation uiview calayer cabasicanimation