DynamicColor icon indicating copy to clipboard operation
DynamicColor copied to clipboard

little enhancement

Open rogomantik opened this issue 9 years ago • 3 comments

You can add the

    public final func readableColor() -> DynamicColor {
        return isLightColor() ? UIColor.blackColor() : UIColor.whiteColor()
    }

and or another that use the inverse / complement at your discretion it's not much related to the colors elaboration it's more an utility that can be useful

rogomantik avatar Sep 24 '16 07:09 rogomantik

I don't know if it would be really helpful because the text can be different than just black or white. I think it is better to let the user choose which color he needs rather than enforce him to use only black or white.

yannickl avatar Sep 26 '16 09:09 yannickl

I thought about this issue and I think we should create a contrasted method that return either the white or the black color to contrast against the receiver.

yannickl avatar Oct 26 '16 20:10 yannickl

Yes maybe somenting constrastingColor(forBackgroundColor: UIColor, foregroungColor: UIColor) -> UIColor that act someway like

background color lightRed foreground color lightRed -> returns darkRed

background color lightRed foreground color lightPink -> returns darkPink

checking backgroundColor.isDark() //ex. false //if foregroundColor == nil returns black // or white for dark backgrounds return foregroundColor.darken(amount: x) // x to be calculated according to WCAG 2.0

rogomantik avatar Oct 28 '16 11:10 rogomantik