title: Custom switch does not show On/Off Image in Xamarin Forms
body: <p><a href="https://www.c-sharpcorner.com/article/how-to-create-and-use-a-custom-switch-control-in-xamarin-forms/" rel="nofollow noreferrer">https://www.c-sharpcorner.com/article/how-to-create-and-use-a-custom-switch-control-in-xamarin-forms/</a></p>
  
  <p>"OnImage" and "OffImage" does not work when i make a custom renderer following the guide above. I see no image when i click on or off.</p>
  
  <p>In my class, I send in a HTTP url and then convert that URL to a UIImage. It works successfully as i've added breakpoints all the way. I even tried with a image in my library to see if that would change the outcome but it didnt.</p>
  
  <pre><code>public class Switch_iOS : SwitchRenderer
  {
      Version version = new Version(ObjCRuntime.Constants.Version);
      protected override void OnElementChanged(ElementChangedEventArgs&lt;Switch&gt; e)
      {
          base.OnElementChanged(e);
          if (e.OldElement != null || e.NewElement == null)
              return;
          var view = (CustomSwitch)Element;
          if (!string.IsNullOrEmpty(view.SwitchThumbImage))
          {
              if (version &gt; new Version(6, 0))
              {   
                  Control.OnImage = FromUrl(view.SwitchThumbImage);
  
                  Control.OffImage = FromUrl(view.SwitchThumbImage);
              }
              else
              {
                  Control.ThumbTintColor = view.SwitchThumbColor.ToUIColor();
              }
          }
      }
  
      public UIImage FromUrl(string uri)
      {
          using (var url = new NSUrl(uri))
          using (var data = NSData.FromUrl(url))
              return UIImage.LoadFromData(data);
      }
  }
  </code></pre>
  
  <p>Is "Control.OnImage" and "Control.OffImage" not working with the latest Xamarin Forms? I also intend to make a background image to the switch.</p>