Skip to content

Instantly share code, notes, and snippets.

@isutton
Created October 25, 2012 09:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save isutton/3951591 to your computer and use it in GitHub Desktop.
Save isutton/3951591 to your computer and use it in GitHub Desktop.
UIWindow subclass that adds rounded top corners.
@interface MyWindow : UIWindow
@end
#import <QuartzCore/QuartzCore.h>
#import "MyWindow.h"
@implementation MyWindow
- (void)layoutSubviews
{
[super layoutSubviews];
CGRect frame = [UIScreen mainScreen].applicationFrame;
UIBezierPath *innerPath = [UIBezierPath bezierPathWithRoundedRect:frame byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(5.0f, 5.0f)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.path = innerPath.CGPath;
self.layer.mask = maskLayer;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment