Skip to content

fix(ios): Correct gradient interpolation for when transitioning to transparent color #52249

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

intergalacticspacehighway
Copy link
Contributor

@intergalacticspacehighway intergalacticspacehighway commented Jun 25, 2025

Summary:

This change fixes an issue on iOS where gradients that fade to a transparent color-stop appear dark or "muddy." The fix ensures that the color's hue is preserved during the transition, matching the behavior on Android and web.

The Problem

When creating a gradient on iOS (e.g., linear-gradient(red, transparent)), the transparent keyword is treated as transparent black (rgba(0,0,0,0)). The CAGradientLayer on iOS then interpolates all color channels linearly, causing the red, green, and blue components of the start color to fade to 0. This transition through black results in an undesirable dark or "muddy" appearance in the middle of the gradient.

Changelog:

[IOS][FIXED] - Gradient interpolation for transparent colors

Test Plan:

Checkout LinearGradient example in RNTester, checkout the newly added transparent color transition example, it should render same on android and iOS.

Before After
linear-gradient(to right, red, transparent) transitions to black on iOS, creating a dark effect. The gradient correctly fades the red color's alpha channel to zero

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Jun 25, 2025
@intergalacticspacehighway intergalacticspacehighway changed the title fix(ios): Correct gradient interpolation for transparent colors fix(ios): Correct gradient interpolation for when transitioning to transparent color Jun 25, 2025
@javache javache requested a review from joevilches June 25, 2025 09:10
@facebook-github-bot
Copy link
Contributor

@NickGerleman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants