Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[UIImage imageWithColor:]

  • Loading branch information...
commit 26d9737c05520914821ef787468431a082b1edaa 1 parent 80d75fc
@mxcl authored
View
3  MBCategories.h
@@ -7,9 +7,10 @@
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
#import "MBActionSheet.h"
#import "UIAlertView+mxcl.h"
-#import "UIColor+mxcl.h"
#import "UIAlertView+mxcl.h"
#import "UIApplication+mxcl.h"
+#import "UIColor+mxcl.h"
+#import "UIImage+mxcl.h"
#import "UITableView+mxcl.h"
#import "UIView+mxcl.h"
#import "UIWebView+mxcl.h"
View
3  MBCategories.m
@@ -7,9 +7,10 @@
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
#import "MBActionSheet.m"
#import "UIAlertView+mxcl.m"
-#import "UIColor+mxcl.m"
#import "UIAlertView+mxcl.m"
#import "UIApplication+mxcl.m"
+#import "UIColor+mxcl.m"
+#import "UIImage+mxcl.m"
#import "UITableView+mxcl.m"
#import "UIView+mxcl.m"
#import "UIWebView+mxcl.m"
View
5 UIImage+mxcl.h
@@ -0,0 +1,5 @@
+#import <UIKit/UIKit.h>
+
+@interface UIImage (mxcl)
++ (id)imageWithColor:(UIColor *)color;
+@end
View
14 UIImage+mxcl.m
@@ -0,0 +1,14 @@
+#import "UIImage+mxcl.h"
+
+@implementation UIImage (mxcl)
++ (UIImage *)imageWithColor:(UIColor *)color {
+ CGRect rect = CGRectMake(0, 0, 11, 11);
+ UIGraphicsBeginImageContext(rect.size);
+ CGContextRef context = UIGraphicsGetCurrentContext();
+ CGContextSetFillColorWithColor(context, [color CGColor]);
+ CGContextFillRect(context, rect);
+ UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
+ UIGraphicsEndImageContext();
+ return img;
+}
+@end
Please sign in to comment.
Something went wrong with that request. Please try again.