Skip to content

Instantly share code, notes, and snippets.

@sneakyness
Created April 19, 2013 19:54
Show Gist options
  • Save sneakyness/5422797 to your computer and use it in GitHub Desktop.
Save sneakyness/5422797 to your computer and use it in GitHub Desktop.
"Empty" (Checkerboard) iOS Background Pattern
UIImage *EmptyBGPattern()
{
CGFloat side = 16;
CGSize size = CGSizeMake(side, side);
UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
[[UIColor whiteColor] setFill];
UIRectFill((CGRect){.size = size});
CGRect r = CGRectMake(0, 0, side / 2, side / 2);
[[UIColor colorWithWhite:0.8f alpha:1] setFill];
UIRectFill(r);
r.origin = CGPointMake(side / 2, side / 2);
UIRectFill(r);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment