Nativescript: Bold, Underline, foregroundColor and Italic not working for label

Created on 20 Jul 2019  路  1Comment  路  Source: NativeScript/NativeScript

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 6.0.0
  • Cross-platform modules: 6.0.1
  • Android Runtime: 6.0.0
  • iOS Runtime: 6.0.1
  • Plugin(s): NA

Describe the bug

Bold, Underline, foregroundColor and Italic not working for label

To Reproduce

Take a look at https://play.nativescript.org/?template=play-tsc&id=em8FoW&v=2

Expected behavior
Bold, Underline, foregroundColor and Italic should work as mentioned at https://www.nativescript.org/blog/bolding-italicizing-and-underlining-portions-of-text-in-nativescript

Sample project

https://play.nativescript.org/?template=play-tsc&id=em8FoW&v=2

Additional context

Most helpful comment

Hi @rakeshgirase,
The described properties in the blog post are deprecated and are no longer supported by the Span. In your scenario, you should replace:

  1. foregroundColor with color
  2. fontAttributes with fontWeight
  3. fontAttributes with fontStyle
  4. underline="true" with textDecoration="underline"
    For your convenience, I am also attaching the demo with the needed changes.

Check out the API reference here, where are described all styling properties for the Span.

>All comments

Hi @rakeshgirase,
The described properties in the blog post are deprecated and are no longer supported by the Span. In your scenario, you should replace:

  1. foregroundColor with color
  2. fontAttributes with fontWeight
  3. fontAttributes with fontStyle
  4. underline="true" with textDecoration="underline"
    For your convenience, I am also attaching the demo with the needed changes.

Check out the API reference here, where are described all styling properties for the Span.

Was this page helpful?
0 / 5 - 0 ratings