我正在通过以下操作为我的 View 添加阴影
- (void)viewDidLoad{
[super viewDidLoad];
self.view.layer.shadowColor = [UIColor blackColor].CGColor;
self.view.layer.shadowOffset = CGSizeMake(0.0f, 0.0f);
self.view.layer.shadowOpacity = 1.0f;
self.view.layer.shadowRadius = 4.0f;
self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.bounds].CGPath;
}
但是,我得到的 View 完全没有阴影,如下所示
我是否错过了中间的一些点。请就这个问题给我建议
最佳答案
您需要将 layer.masksToBounds 设置为 NO,将 clipsToBounds 设置为 YES。
self.view.layer.masksToBounds = NO;
self.view.clipsToBounds = YES;
关于objective-c - 不能给 View 添加阴影,CALayer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13018604/