summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorMarko B. Ludolph <MarkoBL@users.noreply.github.com>2017-08-15 12:14:02 +0200
committerRui Marinho <me@ruimarinho.net>2017-08-15 11:14:02 +0100
commitaf404c55296340d92c3ac4a7cdfdd445b1b06543 (patch)
tree791739394180d3cb311c53aa1ad0f8edfbf040d7 /Xamarin.Forms.Platform.iOS
parentd85d93c4614648b9bb12630c0ca6fc2ab2c512f9 (diff)
downloadxamarin-forms-af404c55296340d92c3ac4a7cdfdd445b1b06543.tar.gz
xamarin-forms-af404c55296340d92c3ac4a7cdfdd445b1b06543.tar.bz2
xamarin-forms-af404c55296340d92c3ac4a7cdfdd445b1b06543.zip
[macOS] Implements/Fixes Vertical Text Alignment in the Label Renderer (#1046)
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs14
1 files changed, 13 insertions, 1 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs
index 0d016e50..5f1157fd 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs
@@ -85,14 +85,26 @@ namespace Xamarin.Forms.Platform.MacOS
Control.Frame = new RectangleF(0, 0, (nfloat)Element.Width, labelHeight);
break;
case TextAlignment.Center:
+
+#if __MOBILE__
Control.Frame = new RectangleF(0, 0, (nfloat)Element.Width, (nfloat)Element.Height);
+#else
+ fitSize = Control.SizeThatFits(Element.Bounds.Size.ToSizeF());
+ labelHeight = (nfloat)Math.Min(Bounds.Height, fitSize.Height);
+ var yOffset = (int)(Element.Height / 2 - labelHeight / 2);
+ Control.Frame = new RectangleF(0, 0, (nfloat)Element.Width, (nfloat)Element.Height - yOffset);
+#endif
break;
case TextAlignment.End:
- nfloat yOffset = 0;
fitSize = Control.SizeThatFits(Element.Bounds.Size.ToSizeF());
labelHeight = (nfloat)Math.Min(Bounds.Height, fitSize.Height);
+#if __MOBILE__
+ nfloat yOffset = 0;
yOffset = (nfloat)(Element.Height - labelHeight);
Control.Frame = new RectangleF(0, yOffset, (nfloat)Element.Width, labelHeight);
+#else
+ Control.Frame = new RectangleF(0, 0, (nfloat)Element.Width, labelHeight);
+#endif
break;
}
}