Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Classes/ShadowBoxingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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];
Expand Down
1 change: 1 addition & 0 deletions Classes/UIBezierPath+ShadowPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
@interface UIBezierPath (ShadowPath)

+ (UIBezierPath*)bezierPathWithCurvedShadowForRect:(CGRect)rect;
+ (UIBezierPath*)bezierPathWithCurvedInsetShadowForRect:(CGRect)rect;

@end
23 changes: 23 additions & 0 deletions Classes/UIBezierPath+ShadowPath.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
4 changes: 2 additions & 2 deletions ShadowBoxing.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down