Maui icon indicating copy to clipboard operation
Maui copied to clipboard

[Bug] On iOS + MacCatalyst, `AvatarView.BackgroundColor` Does Not Work

Open TheCodeTraveler opened this issue 3 years ago • 0 comments

Description

This is a known-issue on iOS + MacCatalyst, noted in the AvatarView Pull Request.

It is a purposefully implemented workaround because there is a bug in .NET MAUI where it paints the BackgroundColor on top of the Image on iOS.

https://github.com/CommunityToolkit/Maui/blob/68b82412a7e31d961b7ec0da2909f38e2a07ff9a/src/CommunityToolkit.Maui/Views/AvatarView.shared.cs#L324-L341

Here's an example of what it looks like without the workaround when setting BackgroundColor = Colors.Black:

Link to Reproduction Sample

https://github.com/CommunityToolkit/Maui/tree/main/samples

Steps to Reproduce

  1. In Visual Studio, launch CommunityToolkit.Maui.Sample.sln
  2. In Visual Studio, set iOS as the target platform
  3. In Visual Studio, build/deploy an iOS app to a simulator or device
  4. In the iOS device, navigate to Views / AvatarView Images Page
  5. In the iOS device, confirm that the Image background color is Transparent

Expected Behavior

The background color of the AvatarView should reflect the BackgroundColor property set by the developer.

Actual Behavior

AvatarView on iOS is hardcoded to set BackgroundColor to Colors.Transparent to work-around a .NET MAUI bug causing the BackgroundColor to be painted over top of the Image.

https://github.com/CommunityToolkit/Maui/blob/68b82412a7e31d961b7ec0da2909f38e2a07ff9a/src/CommunityToolkit.Maui/Views/AvatarView.shared.cs#L324-L341

Workaround

Unknown

Reproduction Imagery

In this example, BackgroundColor = Colors.White:

iOS / MacCatalyst Android
Screenshot_1658459618

TheCodeTraveler avatar Jul 22 '22 03:07 TheCodeTraveler