[iOS] Fix Button image sizing and layout#22476
Merged
tj-devel709 merged 73 commits intomainfrom Aug 27, 2024
Merged
Conversation
Member
Author
|
I think this needs to rethink how the Measure for the button is taken in the case of moving all the layout logic into the ArrangeOverride |
fb92003 to
a6d0772
Compare
44f5aa8 to
3147b11
Compare
tj-devel709
commented
May 23, 2024
jsuarezruiz
reviewed
Jun 12, 2024
b4a6699 to
512c841
Compare
PureWeen
reviewed
Jun 21, 2024
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
696765a to
99ed008
Compare
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
be6e2a1 to
bbb8045
Compare
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
fc5a397 to
a0b7ac6
Compare
PureWeen
requested changes
Jul 18, 2024
Member
PureWeen
left a comment
There was a problem hiding this comment.
Investigate not setting ContentEdgeInsets for the padding to fix issues with clipping
1b0e5af to
61886b8
Compare
PureWeen
approved these changes
Aug 27, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description of Change
This PR is a continuation of this previous PR: #21759.
This PR will now do some of the heavy work to try to resize the image, improve centering especially in situations where the image is above or below the title, respect the padding, spacing, and borderwidth to give more control to the developer, match Windows and Android where it can, and overall give a better button experience on iOS.
Note: With the introduction of the UIButton.Configuration API in the future, button layout will be a little simpler.
Notable Changes in iOS Button
Spacing
iOS will now respect the spacing, padding, borderwidth, and margins more accurately than before. As a result, the default spacing between the image and title will actually show up as 10 units. Previously, the button was trying to set 10 units but actually rendered around 6. The image below shows the old behavior at the top and the new behavior on the bottom. If you want the old behavior, you can manually add

ContentLayout="Left, 6"or whatever width you'd like.Image Resizing
In the old implementation, images would not be resized if they were too large and the padding, borderwidth, spacing, and margins would changes internally to try to fit the button contents if it could. Now the image will be resized to the max size given the padding, borderwidth, spacing, and margins. If there is also a title, the button content may not all fit inside the button and we would recommend that you size your image manually to achieve the layout you desire.
Example 1
Example 2
Example 3
BorderWidth
BorderWidth now matches Windows and should be similar to Android in the future. Before, the button content would be inset by the BorderWidth every time. Now the BorderWidth will try to use the space outside the button if it is available and if it is not, it will use the space inside the button.
In this example below, the top button does not have space outside the button so the BorderWidth will inset the space and the second button has more space available so it will outset the button.
If you'd like to test some cases, here are some code samples:
Issues Fixed
Fixes #22306
Fixes #21285
Fixes #23635