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

Add a support for backgrounds with gradient #2

Merged
merged 2 commits into from Oct 17, 2017
Merged

Add a support for backgrounds with gradient #2

merged 2 commits into from Oct 17, 2017

Conversation

vladvlasov256
Copy link
Contributor

@vladvlasov256 vladvlasov256 commented Aug 26, 2017

gradient is an optional boolean parameter. The colors for gradient can be generated automatically as offsets for the backgroundColor.

Example
randomImage.setImageForName(string: "Michael Bluth", backgroundColor: .cyan, circular: true, textAttributes: nil, gradient: true)

Or with a random color:
randomImage.setImageForName(string: "Michael Bluth", circular: true, textAttributes: nil, gradient: true)

Another version of the setImageForName has an optional tuple named gradientColors. Thus it's possible to specify two explicit colors for the gradient.

Example
randomImage.setImageForName(string: "Michael Bluth", gradientColors: (top: .magenta, bottom: .purple), circular: true, textAttributes: nil)

Copy link
Owner

@bachonk bachonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a cool addition!

I added some notes to use more descriptive function names, but I think it's good to go once that's changed.

return min(max(value, 0), 1)
}

private func correct(color: UIColor, with offset: GradientOffset) -> UIColor {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a more descriptive function name.

return color
}

private func twoColors(from color: UIColor) -> GradientColors {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a more descriptive function name.

@vladvlasov256
Copy link
Contributor Author

I added some notes to use more descriptive function names
Done it. Please, review the renamings.

@bachonk bachonk merged commit b23f88a into bachonk:master Oct 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants