Пример #1
0
        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(Colors.CGColor);
                    context.AddPath(path.CGPath);
                    context.FillPath();

                    context.RestoreState();

                    context.SaveState();
                    context.AddPath(path.CGPath);
                    context.Clip();

                    context.RestoreState();

                    resultImage = UIGraphics.GetImageFromCurrentImageContext();
                }

            return(resultImage);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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 innerBorderBagelPath = BezierPathGenerator.Bagel(center, startRadius, endRadius, 0f, FullCircleAngle))
                {
                    context.SaveState();
                    context.SetFillColor(BGColors.CGColor);
                    innerBorderBagelPath.Fill();
                    context.RestoreState();

                    resultImage = UIGraphics.GetImageFromCurrentImageContext();
                }

            return(resultImage);
        }