A custom renderer is a class that inherits from another renderer. It allows us to add custom code for important events, such as when an element in XAML is created when the XAML file is parsed. Since the ARView control inherits from the View, we will be using ViewRenderer as a base class. Let's create the ARViewRenderer class by going through the following steps:
- In the WhackABox.iOS project, create a folder called Renderers.
- In that folder, add a new class called ARViewRenderer.
- Add the following code to the class:
using System.Threading.Tasks;
using Urho.iOS;
using WhackABox.Controls;
using WhackABox.iOS.Renderers;using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(ARView), typeof(ARViewRenderer))]
namespace WhackABox.iOS.Renderers
{
public class ARViewRenderer : ViewRenderer<ARView, UrhoSurface>
{
protected async override void
OnElementChanged(ElementChangedEventArgs<ARView> e)
...