Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue19007.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Github, 19007, "Incomplete Label Display on macOS and IOS When Padding is Applied", PlatformAffected.iOS)]
public class Issue19007 : ContentPage
{
public Issue19007()
{
var grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(100) });

var label = new Label
{
Background = Colors.Red,
Text = ".NET Multi-platform App UI (.NET MAUI) is a cross-platform framework for creating mobile and desktop apps with C# and XAML.",
Padding = new Thickness(20),
AutomationId = "Label"
};

grid.Children.Add(label);
Grid.SetRow(label, 0);
Grid.SetColumn(label, 0);

Content = grid;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue19007 : _IssuesUITest
{
public Issue19007(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Incomplete Label Display on macOS and IOS When Padding is Applied";

[Test]
[Category(UITestCategories.Label)]
public void LabelWithPadding()
{
App.WaitForElement("Label");
VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/Core/src/Platform/iOS/MauiLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ RectangleF AlignVertical(RectangleF rect)

public override SizeF SizeThatFits(SizeF size)
{
var requestedSize = base.SizeThatFits(size);
// Prior to calculating the text size, reduce the padding, and then add the padding back in the AddInsets method.
var adjustedWidth = size.Width - TextInsets.Left - TextInsets.Right;
var adjustedHeight = size.Height - TextInsets.Top - TextInsets.Bottom;
var requestedSize = base.SizeThatFits(new SizeF(adjustedWidth, adjustedHeight));

// Let's be sure the label is not larger than the container
return AddInsets(new Size()
Expand Down
Loading