public override UIImage GenerateBackgroundImage() { UIImage resultImage; UIGraphics.BeginImageContextWithOptions(BackBounds.Size, false, UIScreen.MainScreen.Scale); var center = new CGPoint(BackBounds.GetMidX(), BackBounds.GetMidY()); using (var context = UIGraphics.GetCurrentContext()) using (var circlePath = UIBezierPath.FromOval(new CGRect(CGPoint.Empty, BackBounds.Size))) using (var borderBagelPath = BezierPathGenerator.Bagel(center, StartBorderRadius, EndBorderRadius, 0f, FullCircleAngle)) using (var innerBorderBagelPath = BezierPathGenerator.Bagel(center, StartBorderRadius + BorderPadding, EndBorderRadius - BorderPadding, 0f, FullCircleAngle)) { context.SaveState(); context.SetFillColor(BackCircleBackgroundColor); circlePath.Fill(); context.RestoreState(); context.SaveState(); context.SetFillColor(BackBorderColor); borderBagelPath.Fill(); context.RestoreState(); context.SaveState(); context.SetFillColor(BackInnerBorderColor); innerBorderBagelPath.Fill(); context.RestoreState(); resultImage = UIGraphics.GetImageFromCurrentImageContext(); } return(resultImage); }
void DrawInnerGlow(CGContext context, CGPoint center, nfloat startRadius, nfloat endRadius, CGColor glowColor, nfloat glowRadius) { using (var innerGlowPath = BezierPathGenerator.Bagel(center, startRadius - glowRadius - GlowOffset, startRadius - GlowOffset, 0f, FullCircleAngle)) using (var outerGlowPath = BezierPathGenerator.Bagel(center, endRadius + GlowOffset, endRadius + glowRadius + GlowOffset, 0f, FullCircleAngle)) { context.SaveState(); #if __UNIFIED__ context.SetShadow(CGSize.Empty, glowRadius, glowColor); #else context.SetShadowWithColor(CGSize.Empty, glowRadius, glowColor); #endif context.SetFillColor(Color.CGColor); context.AddPath(innerGlowPath.CGPath); context.FillPath(); context.RestoreState(); context.SaveState(); #if __UNIFIED__ context.SetShadow(CGSize.Empty, glowRadius, glowColor); #else context.SetShadowWithColor(CGSize.Empty, glowRadius, glowColor); #endif context.SetFillColor(Color.CGColor); context.SetFillColor(Color.CGColor); context.AddPath(outerGlowPath.CGPath); context.FillPath(); context.RestoreState(); } }
protected override UIImage GenerateFullProgressImage() { UIImage resultImage; UIGraphics.BeginImageContextWithOptions(Bounds.Size, false, UIScreen.MainScreen.Scale); using (var context = UIGraphics.GetCurrentContext()) using (var path = BezierPathGenerator.Bagel(CenterPoint, startRadius, endRadius, 0f, FullCircleAngle)) { context.SaveState(); context.SetFillColor(Color.CGColor); context.AddPath(path.CGPath); context.FillPath(); context.RestoreState(); context.SaveState(); context.AddPath(path.CGPath); context.Clip(); DrawGradientOverlay(context); DrawInnerGlow(context, CenterPoint, startRadius, endRadius, GlowColor, GlowRadius); context.RestoreState(); resultImage = UIGraphics.GetImageFromCurrentImageContext(); } return(resultImage); }
public override void DrawInContext(CGContext context) { var progressAngle = CalculateProgressAngle(Percentage); using (var path = BezierPathGenerator.Bagel(CenterPoint, startRadius, endRadius, 0f, progressAngle)) { context.AddPath(path.CGPath); context.Clip(); context.DrawImage(Bounds, fullProgressImage.CGImage); } }