Created
August 15, 2012 19:49
-
-
Save mgcrea/3363043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIBezierPath *buttonPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:self.layer.cornerRadius]; | |
CAShapeLayer* shadowLayer = [CAShapeLayer layer]; | |
//shadowLayer.cornerRadius = 8.0f; | |
[shadowLayer setOpacity:1]; | |
[shadowLayer setBackgroundColor:UIColor.redColor.CGColor]; | |
// Standard shadow stuff | |
[shadowLayer setShadowOpacity:1.0f]; | |
[shadowLayer setShadowColor:[[UIColor colorWithWhite:1 alpha:1] CGColor]]; | |
[shadowLayer setShadowOffset:CGSizeMake(2.0f, 2.0f)]; | |
[shadowLayer setShadowRadius:5]; | |
// Causes the inner region in this example to NOT be filled. | |
[shadowLayer setFillRule:kCAFillRuleEvenOdd]; | |
// Create the larger rectangle path. | |
CGMutablePathRef path = CGPathCreateMutable(); | |
CGPathAddRect(path, NULL, CGRectInset(self.bounds, -42.0f, -42.0f)); | |
// Add the inner path so it's subtracted from the outer path. | |
CGPathAddPath(path, NULL, buttonPath.CGPath); | |
CGPathCloseSubpath(path); | |
[shadowLayer setPath:path]; | |
CGPathRelease(path); | |
[self.layer addSublayer:shadowLayer]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment