If you don't want to change the check boxes on other platforms, you can use a custom renderer to only change how it looks on iOS.
Subclass the CheckBox
in your shared project:
public class CustomCheckBox : CheckBox {}
And add the custom renderer to the iOS project:
using CoreGraphics;
using UIKit;
using Xamarin.Forms.Platform.iOS;
using Xamarin.Forms;
using YourApp.iOS;
using YourApp.Controls; // namespace of your CustomCheckBox
using System.ComponentModel;
[assembly: ExportRenderer(typeof(CustomCheckBox), typeof(CustomCheckBoxRenderer))]
namespace YourApp.iOS
{
public class CustomCheckBoxRenderer : ViewRenderer<CustomCheckBox, UIView>
{
private const float SideLength = 18f;
private bool firstTime = true;
protected override void OnElementChanged(ElementChangedEventArgs<CustomCheckBox> e)
{
base.OnElementChanged(e);
if (Control == null)
{
var checkBox = new UIView();
SetNativeControl(checkBox);
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == CustomCheckBox.IsCheckedProperty.PropertyName || firstTime)
{
SetNeedsDisplay();
}
}
public override void Draw(CGRect rect)
{
Element.Color.ToUIColor().SetStroke();
if (Element.IsChecked)
{
var checkPath = new UIBezierPath();
checkPath.MoveTo(new CGPoint(1 + .2 * SideLength, 1 + .475 * SideLength));
checkPath.AddLineTo(new CGPoint(1 + .45 * SideLength, 1 + .675 * SideLength));
checkPath.AddLineTo(new CGPoint(1 + .8 * SideLength, 1 + .275 * SideLength));
checkPath.LineWidth = 3f;
checkPath.Stroke();
}
var boxPath = UIBezierPath.FromRoundedRect(
new CGRect(1f, 1f, SideLength, SideLength), UIRectCorner.AllCorners, new CGSize(2,2));
boxPath.LineWidth = 2f;
boxPath.Stroke();
firstTime = false;
}
public override CGSize SizeThatFits(CGSize size)
{
return new CGSize(SideLength + 2, SideLength + 2);
}
}
}