Snackbar and Toast messages are omitted when length is equal to display width on iOS #1281
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.
If the Snackbar message length is the same as the display width, the end of the message is omitted.
This PR fixes the problem that the end of the message is omitted when the length of the Snackbar or Toast message is close to the display width.
Description of Change
Auto width adjustment of UILabel now works when Snackbar or Toast message length is close to display width.
[CommunityToolkit.Maui.Core.Views.PlatformToast.macios.cs]
I was set the value of the messageLabel's AdjustsFontSizeToFitWidth property to true.
As a result, if the length of the message is close to the display width, the width of the UILabel will be automatically adjusted and the font size may be slightly reduced, but the end of the message will not be displayed omitted.
Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information
Below is the execution result.
[Snackbar]
Message : 1234567890ABCDEFGHIJKLMNOPQRSTUVW
Message : 1234567890ABCDEFGHIJKLMNOPQRSTUVWXY
Message : 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
[Toast]
Message : 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
Message : 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ123
Message : 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234
If the length of the message is close to the display width, the UILabel's automatic width adjustment will work and the font size will be slightly smaller, but you can see from the execution result that the end of the message is displayed without omitting it.
The following is the verification result when the Font Size is set to 30.
[Snackbar]
Message : 1234567890ABCDEF
Message : 1234567890ABCDEFG
Message : 1234567890ABCDEFGH
[Toast]
Message : 1234567890ABCDEFGH
Message : 1234567890ABCDEFGHI
Message : 1234567890ABCDEFGHJ