https://github.com/tinymind/uicolor-hexrgb
UIColor-HexRGB is easy drop in UIColor category that converts Hex and RGB values to UIColor.
https://github.com/tinymind/uicolor-hexrgb
Last synced: 9 months ago
JSON representation
UIColor-HexRGB is easy drop in UIColor category that converts Hex and RGB values to UIColor.
- Host: GitHub
- URL: https://github.com/tinymind/uicolor-hexrgb
- Owner: tinymind
- License: mit
- Created: 2015-02-04T08:59:17.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2018-02-06T17:51:37.000Z (almost 8 years ago)
- Last Synced: 2025-04-14T16:05:16.306Z (10 months ago)
- Language: Objective-C
- Homepage:
- Size: 71.3 KB
- Stars: 12
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UIColor-HexRGB
UIColor category that converts Hex and RGB color string values to UIColor.
## Supports color formats
- Hex string
- fff (short, without #)
- #fff (short, with #)
- 00ff00 (long, without #)
- #00ff00 (long, with #)
- RGB(A) string
- 99,159,137 (without alpha)
- 99,159,137,0.5 (with alpha)
- Hex integer
- 0x00ff00
## Installation
- Add `UIColor+HexRGB.h` and `UIColor+HexRGB.h` to your project.
- Or use CocoaPods: `pod 'UIColor-HexRGB'`.
## Requirements
Requires iOS 4.3 and above.
## Usage
``` cpp
#import "UIColor+HexRGB.h"
- (void)viewDidLoad {
[super viewDidLoad];
self.label1.backgroundColor = [UIColor colorWithHex: @"2eeea3"];
self.label2.backgroundColor = [UIColor colorWithHex: @"#fd482f"];
self.label3.backgroundColor = [UIColor colorWithRGB: @"99,159,137"];
self.label4.backgroundColor = [UIColor colorWithRGBA: @"137,99,59,0.5"];
self.label5.backgroundColor = [UIColor colorWithHex: @"0f0"];
self.label6.backgroundColor = [UIColor colorWithHexNum: 0xfd482f alpha: 0.5];
}
```
## Example
