Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using Xamarin.Forms.Platform.iOS;
using CoreGraphics;
using UIKit;
using Xamarin.Forms;
using FormsTestApp.iOS;
using FormsTestApp;
[assembly: ExportRenderer(typeof(CrossedOutLabel), typeof(CustomLabelRenderer))]
namespace FormsTestApp.iOS
{
public class CustomLabelRenderer : LabelRenderer
{
public override void Draw (CGRect rect)
{
using (var context = UIGraphics.GetCurrentContext ()) {
ClearCanvas (context, rect);
DrawLine (context, rect);
}
}
static void ClearCanvas (CGContext context, CGRect rect)
{
context.SetFillColor (Color.White.ToCGColor ());
context.FillRect (rect);
}
void DrawLine (CGContext context, CGRect rect)
{
var label = Element as CrossedOutLabel;
context.SetLineWidth (1);
context.SetStrokeColor (label.LineColor.ToCGColor ());
context.SetFillColor (label.BackgroundColor.ToCGColor ());
context.MoveTo (25, 15);
context.AddLineToPoint (100, -8);
context.DrawPath (CGPathDrawingMode.FillStroke);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.