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
11 changes: 2 additions & 9 deletions src/Core/src/Platform/iOS/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,23 +268,16 @@ public static void UpdateBackgroundLayerFrame(this UIView view)

var layer = view.Layer;

UpdateBackgroundLayerFrame(layer, view.Bounds);
}

static void UpdateBackgroundLayerFrame(CALayer layer, CGRect bounds)
{
if (layer == null || layer.Sublayers == null || layer.Sublayers.Length == 0)
return;

foreach (var sublayer in layer.Sublayers)
{
if (sublayer.Name == BackgroundLayerName && sublayer.Frame != bounds)
if (sublayer.Name == BackgroundLayerName && sublayer.Frame != view.Bounds)
{
sublayer.Frame = bounds;
sublayer.Frame = view.Bounds;
break;
}

UpdateBackgroundLayerFrame(sublayer, bounds);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.Maui.DeviceTests.Stubs;
using UIKit;
using Xunit;
Expand All @@ -9,23 +8,6 @@ namespace Microsoft.Maui.DeviceTests.Handlers.ContentView
[Category(TestCategory.ContentView)]
public partial class ContentViewTests
{
[Theory(DisplayName = "Background Updates Correctly")]
[InlineData(0xFF0000)]
[InlineData(0x00FF00)]
[InlineData(0x0000FF)]
public async Task BackgroundUpdatesCorrectly(uint color)
{
var expected = Color.FromUint(color);

var contentView = new ContentViewStub()
{
Content = new LabelStub { Text = "Background", TextColor = Colors.White },
Background = new LinearGradientPaintStub(Colors.Red, Colors.Blue),
};

await ValidateHasColor(contentView, expected);
}

[Fact, Category(TestCategory.FlowDirection)]
public async Task FlowDirectionPropagatesToContent()
{
Expand Down Expand Up @@ -123,18 +105,5 @@ public async Task DoesNotPropagateToContentWithExplicitFlowDirection()

Assert.Equal(UIUserInterfaceLayoutDirection.LeftToRight, labelFlowDirection);
}

Platform.ContentView GetNativeContentView(ContentViewHandler contentViewHandler) =>
contentViewHandler.PlatformView;

Task ValidateHasColor(IContentView contentView, Color color, Action action = null)
{
return InvokeOnMainThreadAsync(() =>
{
var nativeContentView = GetNativeContentView(CreateHandler(contentView));
action?.Invoke();
nativeContentView.AssertContainsColor(color);
});
}
}
}