xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] Label with mixed TextColor and HTML styles ignores style colors on iOS #11566

Open nonubitta opened 4 years ago

nonubitta commented 4 years ago

Description

Recently TextType="Html" bug was fixed for ios (#10989 ) It does somewhat work better now. It respects FontFamily and FontSize. But it doesn't work with TextColor.

Steps to Reproduce

  1. On Android it displays correctly. "This" & "text" as white. "Is" & "Red" as red.
  2. On ios everything shows up as white.
  3. If I remove TextColor="White" tag, it shows red color correctly for "Is" & "Red". I want something like this

red

Expected Behavior

It should apply html formatting wherever applied and also respect TextColor

Actual Behavior

Basic Information

Screenshots

Reproduction Link

Workaround

nonubitta commented 4 years ago

Any update on how long will this take?

pmahend1 commented 4 years ago

Text 1 <Span style='color:teal'>Teal Text</Span> Text2

pmahend1 commented 4 years ago

A workaround I found out is to not to set TextColor property of Label instead

<span style="color:black">Text 1</span> <Span style='color:teal'>Teal Text</Span><span style="color:black">Text2</span>

nonubitta commented 4 years ago

For me the workaround doesn't work. I need to get this bug fixed asap please.

nonubitta commented 3 years ago

Why did get removed? Are we not going to get it fixed? @samhouts ?

danieeis commented 3 years ago

In general aspects it is difficult to apply styles to an html label, since it does not accept font family from html, font-size and a large number of other styles to the labels. You have to guess which labels work to apply such a thing. It would discard completely to use label html to apply styles to it.

AlleSchonWeg commented 2 years ago

Hi, the problem is when the AttributedText from the native control (UIKit.UILabel) is set https://github.com/xamarin/Xamarin.Forms/blob/8b5c97824c85f905eaf8c93115aaa6c5dbf1066e/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs#L469 the TextColor property becomes invalid (Font too). The "working" way shows HtmlLabelPlugin in SetText (https://github.com/matteobortolazzo/HtmlLabelPlugin/blob/8405f1aa717c8fce79c37705123f61a46eb7f687/src/HtmlLabel/iOS/Renderer.cs#L86) XF needs to set ForegroundColor if font is black

jon-peel commented 1 year ago

I know this is reported on iOS, but I am having the same problem on Xamarin UWP. Has anyone been able to find a work-around for this?