Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 15230 [details]
demo of issue, works correctly on Android
When using a custom font that was generated off of Fontello.com to create icons I found on iOS if I change the app text, or the color that the icon changes to a box with a ? in it in iOS. On Android I can change the font color and icon with no problem. Initial loading of the icon or setting of the color however does work on iOS.
I can confirm the same behavior but this is not caused by Forms directly. Will look for workaround
The work around I found was to create different labels for each different state of the label, and change the visibility of the label based on what I want to display. I requires a lot of extra code though for something as mudane as changing text.
I was unable to reproduce this issue in Xcode or Xamarin.iOS. Seems to only occur when the text changes on a button click event. Attempted to reproduce duplo steps but unable to find the culprit.
I think the best solution for this issue is if you make a slight adjustment to your iOS custom renderer:
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
var myFont = UIFont.FromName("fontello", Control.Font.PointSize);
Control.Font = myFont;
Element.FontFamily = myFont.FamilyName;
The difference is simply setting the Element.Fontfamily to the name of your custom font.
In the core LabelRenderer for iOS, we need to reapply the font every time we change the Text, TextColor, etc., and we use the Font property on the Element to do this. If the Font on the Element doesn't match what is on the Control, then whatever was on the Control will be overridden. In your custom renderer, you're updating the Font on the Control, but the Element doesn't know about it. If you update the Element's FontFamily property, then your custom font will stay applied when you change the Text or TextColor.
Please let me know if you have any questions or further issues with this. Thank you!