maui
maui copied to clipboard
[iOS] Allow compat iOS buttons to resize image and to respect spacing and padding
Description of Change
This PR is a continuation of https://github.com/dotnet/maui/pull/20953.
After a lot of discussion and testing, it seems the best solution to fix iOS buttons is to get the compatibility APIs in a better state (able to resize, respect the spacing, and respect the padding) and then introduce the iOS 15+ new Configuration APIs. A good amount of work was put in to place the title and image exactly where we want using precise values for the TitleEdgeInsets and ImageEdgeInsets but we noticed that there was some limitation at seemingly random times where the image and title would be several pixels from where we placed them. Since the iOS 15+ Configuration API takes care of placing the image and title in different image placements, that will have improved behavior.
Below is a demo of the button behavior on iOS. The left simulator is prior to this PR and the right displays the changes from this PR. Pay attention to the resizing of the images, the placement/centering, and then respecting the padding and spacing (distance between the image and text).
https://github.com/dotnet/maui/assets/50846373/b85a8bad-8e0c-456a-8632-b53795ec1a79
Code for the sample above: https://gist.github.com/tj-devel709/716c675a6324c2757f2c84354312a51c
Issues Fixed
Fixes #9734 Fixed #18242