another.im-ios/Monal/Classes/UIColor+Extension.m

27 lines
767 B
Mathematica
Raw Normal View History

2024-11-18 14:53:52 +00:00
//
// UIColor+Extension.m
// Monal
//
// Created by Thilo Molitor on 04.11.21.
// Copyright © 2021 Monal.im. All rights reserved.
//
#import "UIColor+Extension.h"
@implementation UIColor (Extension)
-(BOOL) isLightColor
{
CGFloat colorBrightness = 0;
CGColorSpaceRef colorSpace = CGColorGetColorSpace(self.CGColor);
CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace);
if(colorSpaceModel == kCGColorSpaceModelRGB)
{
const CGFloat* componentColors = CGColorGetComponents(self.CGColor);
colorBrightness = ((componentColors[0] * 299) + (componentColors[1] * 587) + (componentColors[2] * 114)) / 1000;
}
else
[self getWhite:&colorBrightness alpha:0];
return (colorBrightness >= .5f);
}
@end