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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 27 additions & 1 deletion src/Core/src/Platform/iOS/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ public static async Task UpdateBackgroundImageSourceAsync(this UIView platformVi
if (provider == null)
return;

platformView.RemoveBackgroundLayer();
if (imageSource != null)
{
var service = provider.GetRequiredImageSourceService(imageSource);
Expand All @@ -410,7 +411,32 @@ public static async Task UpdateBackgroundImageSourceAsync(this UIView platformVi
if (backgroundImage == null)
return;

platformView.BackgroundColor = UIColor.FromPatternImage(backgroundImage);
var cgImage = backgroundImage.CGImage;
var shouldDisposeCGImage = false;
if (cgImage == null && backgroundImage.CIImage != null)
{
using var context = CoreImage.CIContext.Create();
cgImage = context.CreateCGImage(backgroundImage.CIImage, backgroundImage.CIImage.Extent);
shouldDisposeCGImage = true;
}

if (cgImage == null)
return;

var imageLayer = new StaticCALayer
{
Name = BackgroundLayerName,
Contents = cgImage,
Frame = platformView.Bounds,
ContentsGravity = CoreAnimation.CALayer.GravityResize
};

platformView.BackgroundColor = UIColor.Clear;
platformView.InsertBackgroundLayer(imageLayer, 0);

// Dispose the CGImage if we created it via CreateCGImage.
if (shouldDisposeCGImage)
cgImage?.Dispose();
}
}

Expand Down
Loading