Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue33241.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.Maui.Controls.Shapes;
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 33241, "StackLayout fails to render content while applying Clip, and the layout is placed inside a Border with Background", PlatformAffected.iOS | PlatformAffected.macOS)]
public class Issue33241 : ContentPage
{
public Issue33241()
{
var layout = new VerticalStackLayout();
var label = new Label();
label.Text = "The blue box should have a red box inside of it.";
label.AutomationId = "Label";
layout.Children.Add(label);
var border = new Border
{
HeightRequest = 500,
Background = Colors.SkyBlue,
Padding = 10,
Content =
new Issue33241_CustomView
{
Background = Colors.Red,
Padding = 10
}
};
layout.Children.Add(border);
Content = layout;
}
}

public class Issue33241_CustomView : StackLayout
{
protected override void OnSizeAllocated(double width, double height)
{
this.Clip = new RoundRectangleGeometry { Rect = new Rect(0, 0, width, height) };
base.OnSizeAllocated(width, height);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue33241 : _IssuesUITest
{
public Issue33241(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "StackLayout fails to render content while applying Clip, and the layout is placed inside a Border with Background";

[Test]
[Category(UITestCategories.Border)]
public void ClippedStackLayoutInsideBorderWithBackgroundRendersCorrectly()
{
Comment thread
KarthikRajaKalaimani marked this conversation as resolved.
App.WaitForElement("Label");
VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/Core/src/Platform/iOS/LayerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public static void InsertBackgroundLayer(this UIView control, CALayer background
{
var layer = control.Layer;

// Ensure the background layer always renders behind subview layers,
// even if UIKit reorganizes the sublayer array during layout passes.
// Setting ZPosition before insertion is safe — it's a property on the
// layer object and only takes effect once added to the sublayer hierarchy.
backgroundLayer.ZPosition = -1;

if (index > -1)
layer.InsertSublayer(backgroundLayer, index);
else
Expand Down
3 changes: 2 additions & 1 deletion src/Core/src/Platform/iOS/WrapperView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ public override void LayoutSubviews()
return;

if (_borderView is not null)
{
BringSubviewToFront(_borderView);
}

var child = subviews[0];

child.Frame = Bounds;

if (MaskLayer is not null)
Expand Down
Loading