There is only one tiny mistake in the question that causes the shadow to not be displayed: masksToBounds:YES
also masks the shadow! Here's the correct code:
self.layer.cornerRadius = 8.0f;
self.layer.masksToBounds = NO;
self.layer.borderWidth = 1.0f;
self.layer.shadowColor = [UIColor greenColor].CGColor;
self.layer.shadowOpacity = 0.8;
self.layer.shadowRadius = 12;
self.layer.shadowOffset = CGSizeMake(12.0f, 12.0f);
Unfortunately, this means we cannot mask the content and have a shadow at the same time without tricks.
Remember to #import <QuartzCore/QuartzCore.h>
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…