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.
This commit is contained in:
Todd Anglin
2017-05-26 13:29:04 -05:00
committed by SvetoslavTsenov
parent 26e2748f24
commit 9551418b15

View File

@ -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] }
};
}
}