Created
February 10, 2014 16:21
-
-
Save liamnichols/8918881 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
+ (UIImage *)installButtonBackground:(BOOL)fill | |
{ | |
CGFloat borderWidth = 1.0; | |
CGFloat cornerRadius = 3.0; | |
CGSize size = CGSizeMake((cornerRadius * 2) + 1.0, (cornerRadius * 2) + 1.0); | |
UIColor *buttonColor = [UIColor installButtonColor]; | |
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0); | |
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake((borderWidth / 2), (borderWidth / 2), size.width - borderWidth, size.height - borderWidth) byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)]; | |
[path setLineWidth:borderWidth]; | |
[buttonColor setFill]; | |
[buttonColor setStroke]; | |
[path stroke]; | |
if (fill) | |
{ | |
[path fill]; | |
} | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(cornerRadius, cornerRadius, cornerRadius, cornerRadius)]; | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment