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
[iOS] Fix wrong gray color using transparent in iOS gradients #17696
Conversation
@@ -251,6 +251,31 @@ static NSNumber[] GetCAGradientLayerLocations(List<GradientStop> gradientStops) | |||
} | |||
} | |||
|
|||
static CGColor[] GetCAGradientLayerColors(List<GradientStop> gradientStops) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are mostly pending changes from xamarin/Xamarin.Forms#13401
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this rather be a reference to the code in Core? Instead of a duplicate? Might be possible if the method was internal.
@@ -251,6 +251,31 @@ static NSNumber[] GetCAGradientLayerLocations(List<GradientStop> gradientStops) | |||
} | |||
} | |||
|
|||
static CGColor[] GetCAGradientLayerColors(List<GradientStop> gradientStops) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this rather be a reference to the code in Core? Instead of a duplicate? Might be possible if the method was internal.
{ | ||
if (gradientStop.Color == Colors.Transparent) | ||
{ | ||
var color = gradientStops[index == 0 ? index + 1 : index - 1].Color; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if there are multiple transparent together? trans at 0, trans at 0.3 and then red at 1? Also, what happens if the transparent is between two colors? red, trans, green.
nit: this feels like a for loop instead of foreach. I personally don't like the rando index variable outside the loop. But I am also just weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Received request from Customer Services and Support team, could we get another review?. Thanks in advance. |
Description of Change
Fix wrong gray color using transparent in iOS gradients.
If the GradientStop color is transparent, use the next one Color with Alpha 0. In other case, the effect is not correct because use a Clear default color and can see a black color in the gradient from one to other color.
More info: https://betterprogramming.pub/the-proper-way-of-creating-a-transparent-gradient-layer-in-ios-b082daa866b1
To test the changes can use the added sample to the Frame sample in the .NET MAUI Gallery.
Issues Fixed
Fixes #17366
Fixes #14766