Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[iOS] Fix issue using Brush transparent color in Frame #13401

Merged
merged 5 commits into from
Jul 6, 2021
Merged

Conversation

jsuarezruiz
Copy link
Contributor

@jsuarezruiz jsuarezruiz commented Jan 14, 2021

Description of Change

Fix issue using Brush transparent color in Frame on iOS.
The issue is a kind of grey smudge. The reason for the issue is that our gradient is not going from transparent to white. Not at all! It is, in fact, going from black with zero alpha to white full alpha!. That’s because while our alpha channel is going from 1.0 to 0.0 to achieve the transparency effect, our R, G, and B values are going from 1.0 to 0.0 as well, since the main color of the UIColor.Clear is black.

Issues Resolved

API Changes

None

Platforms Affected

  • iOS

Behavioral/Visual Changes

None

Before/After Screenshots

fix13378

Testing Procedure

Launch Core Gallery and navigate to the issue 13378.

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

@AlleSchonWeg
Copy link
Contributor

@jsuarezruiz
Could you merge this into SR 4?

@jsuarezruiz
Copy link
Contributor Author

Team, could we include this requested fix in the upcoming Release?

{
if (gradientStop.Color == Color.Transparent)
{
var color = gradientStops[index == 0 ? index + 1 : index - 1].Color;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you help me understand the logic here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.
This article explain it well: https://betterprogramming.pub/the-proper-way-of-creating-a-transparent-gradient-layer-in-ios-b082daa866b1

Copy link
Contributor

@rachelkang rachelkang left a comment

Choose a reason for hiding this comment

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

are there any tests you can write for this?

@@ -536,7 +536,7 @@ void UpdateBackground()
if (backgroundColor.IsDefault)
NativeView.BackgroundColor = ColorExtensions.BackgroundColor;
else
NativeView.BackgroundColor = backgroundColor.ToUIColor();
NativeView.BackgroundColor = Element.BackgroundColor.ToUIColor();
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason of this change? wasn't backgroundColor already the color of Element.BackgroundColor ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just reuse the backgroundColor variable, but, is the same.

Copy link
Member

@rmarinho rmarinho Jul 5, 2021

Choose a reason for hiding this comment

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

right but this is another access to the BP can't we just leave as is ?

@rmarinho rmarinho merged commit 27b11cf into 5.0.0 Jul 6, 2021
@rmarinho rmarinho deleted the fix-13378 branch July 6, 2021 08:55
@RenatGaliew
Copy link

RenatGaliew commented Jul 14, 2021

Now i am updating Xamarin.Forms to 5.0.0.83

Don't worked.

<Frame.Background>
          <SolidColorBrush Color="#90333232"/>
</Frame.Background>

@Tommigun1980
Copy link

@RenatGaliew Please file a new bug report if a fix doesn't work, as I am not sure these closed tickets are monitored.

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

Successfully merging this pull request may close these issues.

[Bug] iOS LinearGradientBrush Transparent Color
7 participants