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
28 changes: 28 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue28180.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue28180"
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues">
<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">

<Label
x:Name="LongTextLabel"
AutomationId="LongTextLabel"
Padding = "50"
Text="Welcome to this longer text in a Label that should display it's complete contents, but doesn't really do so when it has Padding applied on IOS."
FontSize="32"
HorizontalOptions="Center"
SemanticProperties.HeadingLevel="Level1" />

<Button
x:Name="ToggleBtn"
Text="Click me"
SemanticProperties.Hint="Toggles longer and shorter text for the second label"
Clicked="OnToggleClicked"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
15 changes: 15 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue28180.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 28180, "Labels with Padding are truncated on iOS", PlatformAffected.iOS | PlatformAffected.macOS)]
public partial class Issue28180 : ContentPage
{
public Issue28180()
{
InitializeComponent();
}

private void OnToggleClicked(object sender, EventArgs e)
{
LongTextLabel.Padding = LongTextLabel.Padding == 50 ? 0 : 50;
}
}
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,26 @@
#if IOSUITEST || MACUITEST

using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue28180 : _IssuesUITest
{
public Issue28180(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Labels with Padding are truncated on iOS";

[Test]
[Category(UITestCategories.Label)]
public void LabelWithPaddingIsNotTruncated()
{
App.WaitForElement("LongTextLabel");
VerifyScreenshot();
}
}

#endif
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.
12 changes: 6 additions & 6 deletions src/Core/src/Platform/iOS/MauiLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ public override void DrawText(RectangleF rect)

RectangleF AlignVertical(RectangleF rect)
{
var frameSize = Frame.Size;
var height = Lines == 1 ? Font.LineHeight : SizeThatFits(frameSize).Height;
var availableSize = rect.Size;
var requiredHeight = Lines == 1 ? Font.LineHeight : base.SizeThatFits(rect.Size).Height;

if (height < frameSize.Height)
if (requiredHeight < availableSize.Height)
{
if (_verticalAlignment == UIControlContentVerticalAlignment.Top)
{
rect.Height = height;
rect.Height = requiredHeight;
}
else if (_verticalAlignment == UIControlContentVerticalAlignment.Bottom)
{
rect = new RectangleF(rect.X, rect.Bottom - height, rect.Width, height);
rect = new RectangleF(rect.X, rect.Bottom - requiredHeight, rect.Width, requiredHeight);
}
}

Expand All @@ -74,7 +74,7 @@ public override SizeF SizeThatFits(SizeF size)
var requestedSize = base.SizeThatFits(new SizeF(adjustedWidth, adjustedHeight));

// Let's be sure the label is not larger than the container
return AddInsets(new Size()
return AddInsets(new Size
{
Width = nfloat.Min(requestedSize.Width, size.Width),
Height = nfloat.Min(requestedSize.Height, size.Height),
Expand Down
Loading