Skip to content

Instantly share code, notes, and snippets.

@nicolas-miari
Created October 18, 2022 05:29
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 nicolas-miari/07381078067be59d7b00eef74c3f1c8f to your computer and use it in GitHub Desktop.
Save nicolas-miari/07381078067be59d7b00eef74c3f1c8f to your computer and use it in GitHub Desktop.
UIImage Create Solid
- (nullable UIImage *)sampleImage {
CGRect bounds = CGRectMake(0, 0, 50, 50);
UIColor *color = [UIColor colorWithDisplayP3Red:1 green:0.5 blue:0.25 alpha:1];
UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0);
[color setFill];
UIRectFill(bounds);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment