How to change background of a label from a Xamarin forms dependency call into Xamarin iOS project?

I have set up a dependency call in my Xamarin forms shared project. I reach the code in my Xamarin iOS project which runs this code block:

using System;
using System.ComponentModel;
using System.Runtime.Remoting.Contexts;
using CoreGraphics;
using Example.Interfaces;
using Example.iOS.PlatformHelpers;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(HtmlFormattedLabel), typeof(HtmlFormattedLabelRender))]
namespace Example.iOS.PlatformHelpers
{
public class HtmlFormattedLabelRender : LabelRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs

        base.OnElementChanged(e);

        var view = (HtmlFormattedLabel)Element;
        if (view == null) return;

        var attr = new NSAttributedStringDocumentAttributes();
        var nsError = new NSError();
        attr.DocumentType = NSDocumentType.HTML;

        Control.AttributedText = new NSAttributedString(view.Text, attr, ref nsError);
    }
}

}

this issue that I am have is that my label background return to Xamarin forms is white. I want to change the color to transparent that was the Xamarin Form background image can be seen. right now it renders like this.

Tagged:

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Try to use

    Control.BackgroundColor = UIColor.Clear;
    
Sign In or Register to comment.