question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Icon Tint Color Behavior does not color images on IOS under certain conditions

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the “Reporting a bug” section on Contributing file?

Current Behavior

I am trying to color icons at runtime in a collectionview based on AppthemeBinding using Maui Community Toolkit IconTint Behavior. The process in the content page loops through each process which queries a server database, once completed the egg timer icon gets replaced with a tick icon based on the response from the server.

For testing purposes i’m using an Await.Delay(500) to simulate the server trip, this is mostly functioning correctly with the exception that the icon tint behavior does not get applied and retains its original color, this is only happening on IOS, on Android it works perfectly. This has also happened on several other views where i have an Await.Delay(), as soon as i remove this, the behavior gets applied. The data is in an observable collection within a collectionview.

Also, if I put an Await.Delay before using Shell.Current.GoToAsync, the icons on my custom navigation bar retain their original color.

Expected Behavior

I’m expecting the icons to adopt the new color like they do when running on android.

Steps To Reproduce

Create a Content Page, in XAML

<Image Source="check" WidthRequest="80" HeightRequest="80" > <Image.Behaviors> <mct:IconTintColorBehavior TintColor="Orange" /> </Image.Behaviors> </Image>

In the code behind or VM: await Task.Delay(1000); await Shell.Current.GoToAsync(nameof(Test_landing));

Run on IOS, the icon retains it’s original color, run on Android and it adopts the new color

Remove the await Task.Delay and it works fine. I’m using await delay to allow a popup page that I have close then displaying a new page based on the selection.

Link to public reproduction project repository

https://github.com/SteveJML/Tint-Image-Test

Environment

- .NET MAUI CommunityToolkit:
- OS:
- .NET MAUI:

Anything else?

Images in a collection view cannot be coloured per item based on the binding. I have images that I wanted to color based on their extension, ie .pdf, docx etc.

Issue Analytics

  • State:open
  • Created 5 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pictoscommented, Apr 16, 2023

@SteveJML looks like this is more a Maui issue than us… The workaround is to add the Behavior on the Loaded event on the page, just like this:

public Test_Image()
    {
        InitializeComponent();

        Loaded += (_, __) =>
        {
            this.img.Behaviors.Add(new IconTintColorBehavior()
            {
                TintColor = Colors.Fuchsia
            });
        };
    }

WHen I did that change it worked 100% of the time

0reactions
pictoscommented, Apr 16, 2023

@SteveJML if you can rise the issue there, it will be great. The root cause is that img.Loaded didn’t trigger, so the IconTintColor behavior will not work

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maui Community Toolkit Icon Tint Behavior issues
This is a known issue that is tracked in Image Loaded Event isn't called under certain conditions on IOS #14622,you can follow up...
Read more >
iOS13 UIButton tint misbehaving
I am dynamically setting the buttons tint colour in viewDidLoad. The result is a button with an icon that have the same colour....
Read more >
Tint color not working in IOS storyboard designer.
I am having trouble getting the tint color to work in the storyboard designer. I added an image (icon) to my assets and...
Read more >
barTintColor not working in iOS 15
Hi,. When I run the following code in application(_ :didFinishLaunchingWithOptions) in iOS 15, the bar color turns transparent (thus, showing the black ...
Read more >
IconTintColorBehavior - .NET MAUI Community Toolkit
The IconTintColorBehavior is a behavior allows you to tint an image.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found