A framework for building native applications using React
fix(ios): Correct gradient interpolation for when transitioning to transparent color (#52249)
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 <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: https://github.com/facebook/react-native/pull/52249 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 | | --- | --- | | <img src="https://github.com/user-attachments/assets/c0bb54ad-ed0e-4a80-b37f-0458af0f1f77" width="300"> | <img src="https://github.com/user-attachments/assets/02da921a-bd0e-45c1-881c-cf6460d5ed43" width="300"> | | `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 | Reviewed By: javache Differential Revision: D77312194 Pulled By: NickGerleman fbshipit-source-id: 053df8e44f52cd22a3f28fd01f583f7d03c66af5
N
nishan (o^▽^o) committed
097d482446b7a03ca0f8c7e0254f4d770e05c79c
Parent: 508b152
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 7/3/2025, 12:55:45 AM