[iOS & Mac] Gradient background size is incorrect when invalidating parent #26057
Labels
platform/iOS 🍎
platform/macOS 🍏
macOS / Mac Catalyst
s/triaged
Issue has been reviewed
s/verified
Verified / Reproducible Issue ready for Engineering Triage
t/bug
Something isn't working
Description
When invalidating a parent, gradient applied to the child fills the entire screen.
In my example, I have a Grid with 2 Rows(40,*) and loaded a button as first row with LinearGradientBrush.
When calling Grid.InvalidateMeasure(), the gradient size fills the entire screen.
Steps to Reproduce
Gradient.zip
Link to public reproduction project repository
No response
Version with bug
9.0.10 SR1
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, macOS
Affected platform versions
No response
Did you find any workaround?
Yes
Rename the gradient relevant layer name to skip size updating for this particaluar layer alone.
private void ButtonLoaded(object? sender, EventArgs e)
{
#if IOS
if(sender is Button button && button.Handler != null && button.Handler.PlatformView != null && button.Handler.PlatformView is UIKit.UIView platformView)
{
if(platformView.Layer != null && platformView.Layer.Sublayers != null)
{
if(platformView.Layer != null && platformView.Layer.Sublayers != null)
{
var layer = platformView.Layer.Sublayers.FirstOrDefault(x => x.Name == "MauiBackgroundLayer");
if( layer != null && layer is CALayer gradientLayer)
{
gradientLayer.Name = "GradientLayer";
}
}
}
}
#endif
Relevant log output
The text was updated successfully, but these errors were encountered: