diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml b/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml
index 1a9a97560863..1431528b4999 100644
--- a/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml
+++ b/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml
@@ -39,6 +39,20 @@
Style="{StaticResource Headline}" />
+
+
+
+
diff --git a/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs b/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs
index c0da6da14881..d269893e2e14 100644
--- a/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs
+++ b/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs
@@ -102,8 +102,11 @@ public static void MapText(IEditorHandler handler, IEditor editor)
public static void MapTextColor(IEditorHandler handler, IEditor editor) =>
handler.PlatformView?.UpdateTextColor(editor);
- public static void MapPlaceholder(IEditorHandler handler, IEditor editor) =>
+ public static void MapPlaceholder(IEditorHandler handler, IEditor editor)
+ {
handler.PlatformView?.UpdatePlaceholder(editor);
+ handler.UpdateValue(nameof(IEditor.CharacterSpacing));
+ }
public static void MapPlaceholderColor(IEditorHandler handler, IEditor editor) =>
handler.PlatformView?.UpdatePlaceholderColor(editor);
diff --git a/src/Core/src/Platform/iOS/MauiTextView.cs b/src/Core/src/Platform/iOS/MauiTextView.cs
index caee95da5a69..9e97e1022161 100644
--- a/src/Core/src/Platform/iOS/MauiTextView.cs
+++ b/src/Core/src/Platform/iOS/MauiTextView.cs
@@ -15,6 +15,7 @@ public class MauiTextView : UITextView
public MauiTextView()
{
_placeholderLabel = InitPlaceholderLabel();
+ UpdatePlaceholderLabelFrame();
Changed += OnChanged;
}
@@ -22,6 +23,7 @@ public MauiTextView(CGRect frame)
: base(frame)
{
_placeholderLabel = InitPlaceholderLabel();
+ UpdatePlaceholderLabelFrame();
Changed += OnChanged;
}
@@ -112,6 +114,8 @@ public override NSAttributedString AttributedText
public override void LayoutSubviews()
{
base.LayoutSubviews();
+
+ UpdatePlaceholderLabelFrame();
ShouldCenterVertically();
}
@@ -126,13 +130,20 @@ UILabel InitPlaceholderLabel()
AddSubview(placeholderLabel);
- var edgeInsets = TextContainerInset;
- var lineFragmentPadding = TextContainer.LineFragmentPadding;
+ return placeholderLabel;
+ }
- placeholderLabel.TextInsets = new UIEdgeInsets(edgeInsets.Top, edgeInsets.Left + lineFragmentPadding,
- edgeInsets.Bottom, edgeInsets.Right + lineFragmentPadding);
+ void UpdatePlaceholderLabelFrame()
+ {
+ if (Bounds != CGRect.Empty && _placeholderLabel is not null)
+ {
+ var x = TextContainer.LineFragmentPadding;
+ var y = TextContainerInset.Top;
+ var width = Bounds.Width - (x * 2);
+ var height = Frame.Height - (TextContainerInset.Top + TextContainerInset.Bottom);
- return placeholderLabel;
+ _placeholderLabel.Frame = new CGRect(x, y, width, height);
+ }
}
void HidePlaceholderIfTextIsPresent(string? value)
diff --git a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs
index d133c6b2c292..20a415c7658c 100644
--- a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs
+++ b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs
@@ -101,6 +101,31 @@ public async Task PlaceholderHiddenWhenControlHasAttributedText()
Assert.True(isHidden);
}
+ [Fact(DisplayName = "Placeholder CharacterSpacing Initializes Correctly")]
+ public async Task PlaceholderCharacterSpacingInitializesCorrectly()
+ {
+ string originalText = "Test";
+ var xplatCharacterSpacing = 4;
+
+ var editor = new EditorStub()
+ {
+ CharacterSpacing = xplatCharacterSpacing,
+ Placeholder = originalText
+ };
+
+ var values = await GetValueAsync(editor, (handler) =>
+ {
+ return new
+ {
+ ViewValue = editor.CharacterSpacing,
+ PlatformViewValue = GetNativePlaceholderCharacterSpacing(handler)
+ };
+ });
+
+ Assert.Equal(xplatCharacterSpacing, values.ViewValue);
+ Assert.Equal(xplatCharacterSpacing, values.PlatformViewValue);
+ }
+
[Fact(DisplayName = "CharacterSpacing Initializes Correctly")]
public async Task CharacterSpacingInitializesCorrectly()
{
@@ -222,6 +247,11 @@ double GetNativeCharacterSpacing(EditorHandler editorHandler)
return editor.AttributedText.GetCharacterSpacing();
}
+ double GetNativePlaceholderCharacterSpacing(EditorHandler editorHandler)
+ {
+ return GetNativePlaceholder(editorHandler).AttributedText.GetCharacterSpacing();
+ }
+
double GetNativeUnscaledFontSize(EditorHandler editorHandler) =>
GetNativeEditor(editorHandler).Font.PointSize;