https://github.com/mxcl/uiimagewithcolor
[UIImage imageWithColor]
https://github.com/mxcl/uiimagewithcolor
Last synced: over 1 year ago
JSON representation
[UIImage imageWithColor]
- Host: GitHub
- URL: https://github.com/mxcl/uiimagewithcolor
- Owner: mxcl
- License: unlicense
- Created: 2014-02-01T18:22:22.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-02-22T11:50:26.000Z (over 2 years ago)
- Last Synced: 2024-05-09T08:15:39.793Z (about 2 years ago)
- Language: Objective-C
- Homepage:
- Size: 8.79 KB
- Stars: 79
- Watchers: 6
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#UIImage+ImageWithColor
[](http://cocoadocs.org/docsets/UIImage+ImageWithColor)
[](http://cocoadocs.org/docsets/UIImage+ImageWithColor)
[](http://cocoadocs.org/docsets/UIImage+ImageWithColor)
**Create (optionally resizable & rounded) plain-colored `UIImages`..**
####CocoaPods
[CocoaPods](http://cocoapods.org/) is the recommended way to use UIImage+ImageWithColor in your project.
* Simply add this line to your `Podfile`: `pod 'UIImage+ImageWithColor'`
* Run `pod install`.
####Manual installation
* Add `UIImage+ImageWithColor` header and implementation to your project (2 files total).
###How To Use It
```objc
@import UIImageWithColor;
//…
UIColor *color = [UIColor colorWithWhite:0 alpha:0.33];
UIImage *img = [UIImage imageWithColor:color];
[self.button setBackgroundImage:img forControlState:UIControlStateNormal];
// or if you need an image with dimensions greater than 1x1 pixels
UIColor *color = [UIColor redColor];
UIImage *img = [UIImage imageWithColor:color size:CGSizeMake(20, 20)];
[self.button setBackgroundImage:img forControlState:UIControlStateNormal];
// or if you need a resizable/stretchable image with rounded corners
UIColor *color = [UIColor purpleColor];
UIImage *img = [UIImage resizableImageWithColor:color cornerRadius:10];
[self.button setBackgroundImage:img forControlState:UIControlStateNormal];
```
###Author
Created and maintained by Max Howell ([@Max Howell](https://twitter.com/mxcl)).
###License
This is free and unencumbered software released into the public domain.