From 9551418b15a7aa73d3c15d19175073423d60a117 Mon Sep 17 00:00:00 2001 From: Todd Anglin Date: Fri, 26 May 2017 13:29:04 -0500 Subject: [PATCH] Fixing Button text alignment behavior This change switches iOS Button text alignment from using the generic `nativeView.contentHorizontalAlignment` to using the Button's `nativeView.titleLabel.textAlignment`. This change allows text in a Button to properly center align when wrapped on to multiple lines. Left and Right alignment behavior are unchanged, but using new syntax for consistency. --- tns-core-modules/ui/button/button.ios.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tns-core-modules/ui/button/button.ios.ts b/tns-core-modules/ui/button/button.ios.ts index 3124a81be..0df531095 100644 --- a/tns-core-modules/ui/button/button.ios.ts +++ b/tns-core-modules/ui/button/button.ios.ts @@ -145,16 +145,16 @@ export class Button extends ButtonBase { [textAlignmentProperty.setNative](value: TextAlignment) { switch (value) { - case "left": - this.nativeView.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Left; - break; - case "initial": - case "center": - this.nativeView.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Center; - break; - case "right": - this.nativeView.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Right; - break; + case "left": + this.nativeView.titleLabel.textAlignment = NSTextAlignment.Left; + break; + case "initial": + case "center": + this.nativeView.titleLabel.textAlignment = NSTextAlignment.Center; + break; + case "right": + this.nativeView.titleLabel.textAlignment = NSTextAlignment.Right; + break; } } @@ -193,4 +193,4 @@ class TapHandlerImpl extends NSObject { public static ObjCExposedMethods = { "tap": { returns: interop.types.void, params: [interop.types.id] } }; -} \ No newline at end of file +}