如果您想要一个没有图像的阴影,那么请寻求Mike Weller's解决方案,explicit shadow rect老实说,我比我的更喜欢这个答案,但作为替代方案,您可以尝试设置maskToBOunds并NO添加一个shadowPath喜欢:
 // Set your basic shadow properties.
 imageView.layer.shadowColor = [[UIColor purpleColor] CGColor];
 imageView.layer.shadowOpacity = 1.0f;
 imageView.layer.shadowOffset = CGSizeMake(0, 1.0f);
 imageView.layer.shadowRadius = 1.0;
 // Unmask from bounds
 imageView.layer.masksToBounds = NO;
 // Create a UIBezierPath
 UIBezierPath *path = [UIBezierPath bezierPathWithRect:imageView.bounds];
 // Set the UIBezierPath (path) to the shadowPath
 imageView.layer.shadowPath = [path CGPath];
预先警告,如果用于很多事情,这会影响性能,但如果用于一两件事情,我只会注意到如果有任何性能影响较小。
但就像我说我喜欢Mike Weller's解决方案一样,我非常喜欢它,我可能会自己更改代码。我只提供一个替代方案。