ColorUtils.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // ColorUtils.h
  3. //
  4. // Version 1.1.3
  5. //
  6. // Created by Nick Lockwood on 19/11/2011.
  7. // Copyright (c) 2011 Charcoal Design
  8. //
  9. // Distributed under the permissive zlib License
  10. // Get the latest version from here:
  11. //
  12. // https://github.com/nicklockwood/ColorUtils
  13. //
  14. // This software is provided 'as-is', without any express or implied
  15. // warranty. In no event will the authors be held liable for any damages
  16. // arising from the use of this software.
  17. //
  18. // Permission is granted to anyone to use this software for any purpose,
  19. // including commercial applications, and to alter it and redistribute it
  20. // freely, subject to the following restrictions:
  21. //
  22. // 1. The origin of this software must not be misrepresented; you must not
  23. // claim that you wrote the original software. If you use this software
  24. // in a product, an acknowledgment in the product documentation would be
  25. // appreciated but is not required.
  26. //
  27. // 2. Altered source versions must be plainly marked as such, and must not be
  28. // misrepresented as being the original software.
  29. //
  30. // 3. This notice may not be removed or altered from any source distribution.
  31. //
  32. #pragma GCC diagnostic push
  33. #pragma GCC diagnostic ignored "-Wauto-import"
  34. #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis"
  35. #import <UIKit/UIKit.h>
  36. @interface UIColor (ColorUtils)
  37. @property (nonatomic, readonly) CGFloat red;
  38. @property (nonatomic, readonly) CGFloat green;
  39. @property (nonatomic, readonly) CGFloat blue;
  40. @property (nonatomic, readonly) CGFloat alpha;
  41. + (void)registerColor:(UIColor *)color forName:(NSString *)name;
  42. + (instancetype)colorWithString:(NSString *)string;
  43. + (instancetype)colorWithRGBValue:(uint32_t)rgb;
  44. + (instancetype)colorWithRGBAValue:(uint32_t)rgba;
  45. - (instancetype)initWithString:(NSString *)string;
  46. - (instancetype)initWithRGBValue:(uint32_t)rgb;
  47. - (instancetype)initWithRGBAValue:(uint32_t)rgba;
  48. - (uint32_t)RGBValue;
  49. - (uint32_t)RGBAValue;
  50. - (NSString *)stringValue;
  51. - (BOOL)isMonochromeOrRGB;
  52. - (BOOL)isEquivalent:(id)object;
  53. - (BOOL)isEquivalentToColor:(UIColor *)color;
  54. - (instancetype)colorWithBrightness:(CGFloat)brightness;
  55. - (instancetype)colorBlendedWithColor:(UIColor *)color factor:(CGFloat)factor;
  56. @end
  57. #pragma GCC diagnostic pop