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

@ -146,14 +146,14 @@ export class Button extends ButtonBase {
[textAlignmentProperty.setNative](value: TextAlignment) {
switch (value) {
case "left":
this.nativeView.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Left;
this.nativeView.titleLabel.textAlignment = NSTextAlignment.Left;
break;
case "initial":
case "center":
this.nativeView.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Center;
this.nativeView.titleLabel.textAlignment = NSTextAlignment.Center;
break;
case "right":
this.nativeView.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Right;
this.nativeView.titleLabel.textAlignment = NSTextAlignment.Right;
break;
}
}