diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.h b/MVMCoreUI/Categories/UIColor+MFConvenience.h index 97280ba1..2bb81cd8 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.h +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.h @@ -187,4 +187,8 @@ + (nullable NSString *)hexStringForColor:(nonnull UIColor*)color; + (nonnull UIColor *)mfGetColorForHexWithTransparency:(nonnull NSString *)hexString; + +// Returns if the color is dark or not +- (BOOL)isDark; + @end diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.m b/MVMCoreUI/Categories/UIColor+MFConvenience.m index 8786df01..c185e7bb 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.m +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.m @@ -403,4 +403,10 @@ } } +- (BOOL)isDark { + CGFloat greyScale = 0; + [self getWhite:&greyScale alpha:nil]; + return greyScale < 0.5; +} + @end