Last active
August 29, 2015 14:16
-
-
Save ajonno/0f988d8f08616fbfc4b1 to your computer and use it in GitHub Desktop.
Create circle using Core Graphics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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