Last active
January 2, 2016 13:59
-
-
Save shiweifu/8314215 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
readme |
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
license |
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
// | |
// Created by shiweifu on 14-1-8. | |
// Copyright (c) 2014 weifu. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface UIImage (imageWithColor) | |
+ (UIImage *)imageWithColor:(UIColor *)color; | |
+ (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size; | |
@end |
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
// | |
// Created by shiweifu on 14-1-8. | |
// Copyright (c) 2014 weifu. All rights reserved. | |
// | |
#import "UIImage+imageWithColor.h" | |
@implementation UIImage (imageWithColor) | |
+ (UIImage *)imageWithColor:(UIColor *)color { | |
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); | |
UIGraphicsBeginImageContext(rect.size); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetFillColorWithColor(context, [color CGColor]); | |
CGContextFillRect(context, rect); | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} | |
+ (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size { | |
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height); | |
UIGraphicsBeginImageContext(rect.size); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetFillColorWithColor(context, [color CGColor]); | |
CGContextFillRect(context, rect); | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} | |
@end |
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
Pod::Spec.new do |s| | |
s.name = "UIImage-imageWithColor" | |
s.version = "0.1" | |
s.summary = "test gist" | |
s.homepage = "https://gist.github.com/shiweifu/8314215" | |
s.author = { "weifu shi" => "[email protected]" } | |
s.platform = :ios | |
#s.source = { :git => "git://gist.github.com/6009092.git", :tag => '0.1' } | |
s.source = { :git => "git://gist.github.com/8314215.git"} | |
s.requires_arc = true | |
s.ios.deployment_target = '5.0' | |
s.source_files = '*.{h,m}' | |
s.license = { :type => 'MIT', :file => 'LICENSE' } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment