Skip to content

Instantly share code, notes, and snippets.

@liamnichols
Created February 10, 2014 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liamnichols/8918881 to your computer and use it in GitHub Desktop.
Save liamnichols/8918881 to your computer and use it in GitHub Desktop.
+ (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