Skip to content

[iOS] TintColor on UIButton image no longer working when button made visible #25093

@kklose23

Description

@kklose23

Description

image

This was a regression with the 8.0.90 update. We have a custom behavior IconTintColorBehavior based off the CommunityToolkit behavior of the same name.

Specifically, this is what colors the UIButton image in that behavior:

var image = button.ImageView.Image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
button.SetImage(image, UIControlState.Normal);

var platformColor = color.ToPlatform();
button.TintColor = platformColor;
button.ImageView.TintColor = platformColor;

It looks like what caused this to stop working was the following code which can be found in Button.iOS.cs in function ResizeImageIfNecessary:

image = image?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);

platformButton.SetImage(image, UIControlState.Normal);

(This is because the UIImage needs a rendering mode of type AlwaysTemplate for TintColor to work)

Steps to Reproduce

  1. Open attached repo
  2. Click button to show second button
  3. Second button's icon will not be colored red

Link to public reproduction project repository

https://github.com/kklose23/maui-uibutton-tint

Version with bug

8.0.90 SR9

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.82 SR8.2

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-buttonButton, ImageButtonplatform/iospotential-regressionThis issue described a possible regression on a currently supported version., verification pendingt/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions