I am trying to implement an interface where there are five pages that you can scroll and drag between them, but you can also change the page by clicking on the tabbed bar at the bottom.
I am writing my own renderer for CarouselPage, but I can’t add a tab bar below because iOS UITabBar also needs an array of UIViewControllers to switch between them, and I only have access to the pages.
This is what I have tried so far:
[assembly: ExportRenderer (typeof (ExtendedCarouselPage), typeof (ExtendedCarouselPageRenderer))]
namespace CustomRenderer.iOS
{
public class ExtendedCarouselPageRenderer : CarouselPageRenderer
{
protected UITabBar tabBar;
protected override void OnElementChanged (VisualElementChangedEventArgs e)
{
base.OnElementChanged (e);
tabBar = new UITabBar (new CGRect (0, this.View.Frame.Height * 0.9, this.View.Frame.Width, this.View.Frame.Height * 0.1));
tabBar.Items = new UITabBarItem[]{
new UITabBarItem("Hello",UIImage.FromFile("Homeicon.png"),UIImage.FromFile("HomeiconBlue.png")),
new UITabBarItem("World", UIImage.FromFile("Homeicon.png"),UIImage.FromFile("HomeiconBlue.png"))
};
tabBar.Bounds = new CGRect (0, this.View.Frame.Height * 0.9, this.View.Frame.Width, this.View.Frame.Height * 0.1);
tabBar.Frame = new CGRect (0, this.View.Frame.Height * 0.9, this.View.Frame.Width, this.View.Frame.Height * 0.1);
this.NativeView.AddSubview(tabBar);
}
}
}
The problem is that I cannot find many guides for writing more complex custom renderings. There is a lot to do for Xamarin iOS, but most of the code does not apply to custom rendering.