diff --git a/Classes/ShadowBoxingViewController.m b/Classes/ShadowBoxingViewController.m index b716e54..e35e9e0 100644 --- a/Classes/ShadowBoxingViewController.m +++ b/Classes/ShadowBoxingViewController.m @@ -15,6 +15,8 @@ @implementation ShadowBoxingViewController - (void)viewDidLoad { [super viewDidLoad]; + self.view.backgroundColor = [UIColor underPageBackgroundColor]; + UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 375.0)]; view.center = self.view.center; view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | @@ -23,10 +25,10 @@ - (void)viewDidLoad { view.layer.borderColor = [UIColor colorWithWhite:1.0 alpha:1.0].CGColor; view.layer.borderWidth = 5.0; view.layer.shadowOffset = CGSizeMake(0, 3); - view.layer.shadowOpacity = 0.7; + view.layer.shadowOpacity = 0.3; view.layer.shouldRasterize = YES; - UIBezierPath *path = [UIBezierPath bezierPathWithCurvedShadowForRect:view.bounds]; + UIBezierPath *path = [UIBezierPath bezierPathWithCurvedInsetShadowForRect:view.bounds]; view.layer.shadowPath = path.CGPath; [self.view addSubview:view]; diff --git a/Classes/UIBezierPath+ShadowPath.h b/Classes/UIBezierPath+ShadowPath.h index 956f438..7b677d6 100644 --- a/Classes/UIBezierPath+ShadowPath.h +++ b/Classes/UIBezierPath+ShadowPath.h @@ -11,5 +11,6 @@ @interface UIBezierPath (ShadowPath) + (UIBezierPath*)bezierPathWithCurvedShadowForRect:(CGRect)rect; ++ (UIBezierPath*)bezierPathWithCurvedInsetShadowForRect:(CGRect)rect; @end diff --git a/Classes/UIBezierPath+ShadowPath.m b/Classes/UIBezierPath+ShadowPath.m index 7e1f418..6c1e0b6 100644 --- a/Classes/UIBezierPath+ShadowPath.m +++ b/Classes/UIBezierPath+ShadowPath.m @@ -10,6 +10,7 @@ static const CGFloat offset = 10.0; static const CGFloat curve = 5.0; +static const CGFloat inset = 10.0; @implementation UIBezierPath (ShadowPath) @@ -34,4 +35,26 @@ + (UIBezierPath*)bezierPathWithCurvedShadowForRect:(CGRect)rect { return path; } + ++ (UIBezierPath*)bezierPathWithCurvedInsetShadowForRect:(CGRect)rect { + + UIBezierPath *path = [UIBezierPath bezierPath]; + + CGPoint topLeft = CGPointMake(inset, 0.0); + CGPoint bottomLeft = CGPointMake(inset, CGRectGetHeight(rect)+offset); + CGPoint bottomMiddle = CGPointMake(CGRectGetWidth(rect)/2, CGRectGetHeight(rect)-curve); + CGPoint bottomRight = CGPointMake(CGRectGetWidth(rect) - inset, CGRectGetHeight(rect)+offset); + CGPoint topRight = CGPointMake(CGRectGetWidth(rect) - inset, 0.0); + + [path moveToPoint:topLeft]; + [path addLineToPoint:bottomLeft]; + [path addQuadCurveToPoint:bottomRight + controlPoint:bottomMiddle]; + [path addLineToPoint:topRight]; + [path addLineToPoint:topLeft]; + [path closePath]; + + return path; +} + @end diff --git a/ShadowBoxing.xcodeproj/project.pbxproj b/ShadowBoxing.xcodeproj/project.pbxproj index 9631df8..94c14cf 100755 --- a/ShadowBoxing.xcodeproj/project.pbxproj +++ b/ShadowBoxing.xcodeproj/project.pbxproj @@ -228,7 +228,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = iphoneos3.2; + SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = 2; }; name = Debug; @@ -244,7 +244,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PREBINDING = NO; - SDKROOT = iphoneos3.2; + SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = 2; }; name = Release;