Last active
December 10, 2015 20:59
-
-
Save weekwood/4492055 to your computer and use it in GitHub Desktop.
UINavigationBar rounded corners
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
CALayer *capa = [self.navigationController navigationBar].layer; | |
[capa setShadowColor: [[UIColor blackColor] CGColor]]; | |
[capa setShadowOpacity:0.85f]; | |
[capa setShadowOffset: CGSizeMake(0.0f, 1.5f)]; | |
[capa setShadowRadius:2.0f]; | |
[capa setShouldRasterize:YES]; | |
//Round | |
CGRect bounds = capa.bounds; | |
bounds.size.height += 10.0f; | |
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:bounds | |
byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) | |
cornerRadii:CGSizeMake(10.0, 10.0)]; | |
CAShapeLayer *maskLayer = [CAShapeLayer layer]; | |
maskLayer.frame = bounds; | |
maskLayer.path = maskPath.CGPath; | |
[capa addSublayer:maskLayer]; | |
capa.mask = maskLayer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment