react-native-navigation的迁移库

Color.m 899B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #import "Color.h"
  2. @interface Color()
  3. @property (nonatomic, retain) UIColor* value;
  4. @end
  5. @implementation Color
  6. - (instancetype)initWithValue:(UIColor *)value {
  7. return [super initWithValue:value];
  8. }
  9. - (UIColor *)get {
  10. return self.value;
  11. }
  12. - (UIColor *)getWithDefaultValue:(id)defaultValue {
  13. return [super getWithDefaultValue:defaultValue];
  14. }
  15. -(NSString *)description {
  16. return [self hexStringFromColor:[self getWithDefaultValue:nil]];
  17. }
  18. - (NSString *)hexStringFromColor:(UIColor *)color {
  19. const CGFloat *components = CGColorGetComponents(color.CGColor);
  20. CGFloat r = components[0];
  21. CGFloat g = components[1];
  22. CGFloat b = components[2];
  23. return [NSString stringWithFormat:@"#%02lX%02lX%02lX",
  24. lroundf(r * 255),
  25. lroundf(g * 255),
  26. lroundf(b * 255)];
  27. }
  28. @end