mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +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
@ -145,16 +145,16 @@ export class Button extends ButtonBase {
|
|||||||
|
|
||||||
[textAlignmentProperty.setNative](value: TextAlignment) {
|
[textAlignmentProperty.setNative](value: TextAlignment) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case "left":
|
case "left":
|
||||||
this.nativeView.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Left;
|
this.nativeView.titleLabel.textAlignment = NSTextAlignment.Left;
|
||||||
break;
|
break;
|
||||||
case "initial":
|
case "initial":
|
||||||
case "center":
|
case "center":
|
||||||
this.nativeView.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Center;
|
this.nativeView.titleLabel.textAlignment = NSTextAlignment.Center;
|
||||||
break;
|
break;
|
||||||
case "right":
|
case "right":
|
||||||
this.nativeView.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Right;
|
this.nativeView.titleLabel.textAlignment = NSTextAlignment.Right;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,4 +193,4 @@ class TapHandlerImpl extends NSObject {
|
|||||||
public static ObjCExposedMethods = {
|
public static ObjCExposedMethods = {
|
||||||
"tap": { returns: interop.types.void, params: [interop.types.id] }
|
"tap": { returns: interop.types.void, params: [interop.types.id] }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user