-
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] Fix Button image sizing and layout #22476
Conversation
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b4a6699
to
512c841
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
696765a
to
99ed008
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
be6e2a1
to
bbb8045
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
fc5a397
to
a0b7ac6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Investigate not setting ContentEdgeInsets for the padding to fix issues with clipping
1b0e5af
to
61886b8
Compare
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