mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
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:

committed by
SvetoslavTsenov

parent
26e2748f24
commit
9551418b15
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user