Skip to content

Instantly share code, notes, and snippets.

@prashantvc
Created June 12, 2015 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prashantvc/3a0ab3de9c21469661f4 to your computer and use it in GitHub Desktop.
Save prashantvc/3a0ab3de9c21469661f4 to your computer and use it in GitHub Desktop.
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