public override void DrawInContext(CoreGraphics.CGContext ctx) { base.DrawInContext(ctx); var rect = this.Frame; switch (Type) { case GradientType.Linear: linearGradient.Draw(ctx, rect); break; case GradientType.Radial: radialGradient.Draw(ctx, rect); break; case GradientType.Ellipse: ellipticalGradient.Draw(ctx, rect); break; case GradientType.Multi: multiGradient.Draw(ctx, rect); break; default: throw new NotImplementedException("The target gradient type is not supported: " + Type); } }
public static Shader Draw(this RadialGradient target, RectF bounds) { var center = new PointF((bounds.Width() * target.Center.X), (bounds.Height() * target.Center.Y)); var radius = (float)Math.Min(bounds.Width() / 2f, bounds.Height() / 2f); return(target.Draw(center, radius)); }
public override void Draw(CGRect rect) { base.Draw(rect); using (CGContext ctx = UIGraphics.GetCurrentContext()) { switch (Type) { case GradientType.Linear: linearGradient.Draw(ctx, rect); break; case GradientType.Radial: radialGradient.Draw(ctx, rect); break; case GradientType.Ellipse: ellipticalGradient.Draw(ctx, rect); break; case GradientType.Multi: multiGradient.Draw(ctx, rect); break; default: throw new NotImplementedException("The target gradient type is not supported: " + Type); } } }