nativescriptangular2-nativescript

NativeScript: max number of lines on a Label


If I add textWrap="true" to a Label, text is wrapped over several lines, so far so good.

But I have a very long string and our design only have room for two lines. How do I limit the Label to max two lines?

I'd prefer not to set a height, since that would leave an empty line for texts that could fit on one line?


Solution

  • Let's try this:

    For Android:

    myLabel.android.setMaxLines(2);
    

    For iOS:

    myLabel.ios.numberOfLines = 2