-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] button.SetBackgroundImage(image, state) does not work #21265
Comments
@kassemyu can you use the VSM that's built into .NET MAUI? if you want to replace how .NET MAUI is handling background your best bet is to use mappers to replace how .NET MAUI is setting the background https://learn.microsoft.com/en-us/dotnet/maui/user-interface/handlers/customize?view=net-maui-8.0 |
@PureWeen thanks for your reply. I forgot to mention that I use handlers to design iOS and Android buttons (migration from renderers to handlers). I don't use visual state managers in this case. After writing this ticket I found a workaround with Mappers. When having a mapper for Button.IsPressed, the native button states "Normal" and "Highlighted" are triggered when the button is pressed. I change the background color respectively via:
Previously, I was using a rounded rectangle shape which is then colored and displayed as background via
Other functions using the state such as
work fine. The issue seems to be in the button.SetBackgroundImage. |
@kassemyu Do you think this is still a MAUI issue? or something specific to iOS? Is this something you could test with a MAUI iOS app (not using our cross platform elements) see if that acts accordingly? |
Hey @PureWeen, it was working on Xamarin that way so I suspect it to be a MAUI issue, I can't tell for sure unfortunately. |
Since you are overriding the background logic, you might just need to disable the mapper: builder
.ConfigureMauiHandlers(handlers =>
{
// do not map the background
ButtonHandler.Mapper.ReplaceMapping("Background", (handler, view) => {
});
}); |
Hi @kassemyu. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. |
Description
Hey,
the button.SetBackgroundImage(image, state) seems to not work. Changing the background color works, which is unfortunately not sufficient because I need to show different backgrounds for different states. I saw that 8.0.6 had a fix for the ContentPage background in #17789 and a similar bug was resolved in nightly version for 8.0.0 in #12959 but somehow is still present according to the last comment of the thread. Are there any workarounds for this?
Thanks in advance!
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
8.0.6 SR1
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: