diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.h b/MVMCoreUI/Categories/UIColor+MFConvenience.h index 97280ba1..10e9433d 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.h +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.h @@ -183,8 +183,12 @@ // Returns a gradient lighter color; + (nonnull UIColor *)mfGradientColor:(nullable UIColor *)color; +// Returns if the color is dark or not +- (BOOL)isDark; + #pragma mark - Hex String + (nullable NSString *)hexStringForColor:(nonnull UIColor*)color; + (nonnull UIColor *)mfGetColorForHexWithTransparency:(nonnull NSString *)hexString; + @end diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.m b/MVMCoreUI/Categories/UIColor+MFConvenience.m index 8786df01..cd809509 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.m +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.m @@ -389,6 +389,12 @@ return [UIColor whiteColor]; } +- (BOOL)isDark { + CGFloat greyScale = 0; + [self getWhite:&greyScale alpha:nil]; + return greyScale < 0.5; +} + #pragma mark - Hex String + (nullable NSString *)hexStringForColor:(nonnull UIColor*)color {