Skip to content

Instantly share code, notes, and snippets.

@jbristowe
Last active November 2, 2015 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbristowe/0d3ef7c9214e82487b52 to your computer and use it in GitHub Desktop.
Save jbristowe/0d3ef7c9214e82487b52 to your computer and use it in GitHub Desktop.

How To: Wrap Text in a Button with NativeScript

It's pretty simple. Let's assume the following element in your markup:

<Button text="Hello! Is it me you're looking for?" id="wrapButton" />

By default, Android and iOS truncate the text. You can override this behaviour with the following code:

var wrapButton = page.getViewById("wrapButton");
if (app.android) {
  wrapButton.android.singleLine = false;
} else if (app.ios) {
  wrapButton.ios.titleLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping;
}

Here's how it looks:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment