Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

little enhancement #15

Open
rogomantik opened this issue Sep 24, 2016 · 3 comments
Open

little enhancement #15

rogomantik opened this issue Sep 24, 2016 · 3 comments

Comments

@rogomantik
Copy link

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

@yannickl
Copy link
Owner

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
Copy link
Owner

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.

@rogomantik
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants