Skip to content

Instantly share code, notes, and snippets.

@ajonno
Last active August 29, 2015 14:16
Show Gist options
  • Save ajonno/0f988d8f08616fbfc4b1 to your computer and use it in GitHub Desktop.
Save ajonno/0f988d8f08616fbfc4b1 to your computer and use it in GitHub Desktop.
Create circle using Core Graphics
public class CircleView : UIView
{
private UIColor color;
public CircleView (UIColor color)
{
this.color = color;
}
public override void Draw (CGRect rect)
{
base.Draw (rect);
var path = UIBezierPath.FromOval (rect);
color.SetColor ();
path.Fill();
}
}
public override void ViewDidLoad ()
{
 base.ViewDidLoad ();
 var circ = new CircleView (UIColor.Green);
 circ.Frame = new CGRect (100, 100, 100, 100);
 circ.BackgroundColor = UIColor.White;
 View.AddSubview (circ);

 var circ2 = new CircleView (UIColor.Red);
 circ2.Frame = new CGRect (220, 100, 100, 100);
 circ2.BackgroundColor = UIColor.White;
 View.AddSubview (circ2);

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment