-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
base: main
Are you sure you want to change the base?
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
|
||
namespace Microsoft.Maui.Controls | ||
{ | ||
public partial class Button | ||
{ | ||
CGSize _originalImageSize = CGSize.Empty; | ||
|
||
protected override Size MeasureOverride(double widthConstraint, double heightConstraint) |
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.
Note: To add MeasureOverride, I needed to add this method to the publicAPI.Unshipped. Do-able for SR?
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.
Description of Change
This PR is a continuation of this previous PR: #21759.
The past PR was rolled-back because it contained an infinite loop in certain circumstances when the parent of the button was resized.
To combat this, the iOS button layout code was moved to the ArrangeOverride method with the size allotted from the parent. This also matches where Android and Windows calculates and arranges the layout.
UITest changing the parent size and rotation:
ButtonRotationResizing.mov
UITest testing the measuring code and changing the image position:
iOSButtonChangingLayoutPosition.mov
UITest testing the image resizing when BorderWidth changes
iOSButtonBorderWidth.mov
If you'd like to test some cases, here are some code samples:
Issues Fixed
Fixes #22306