View cycle progress as an activity app

I am trying to create an animated radial diagram that looks like an activity application created by Apple. I provide an image to show what I would like to receive:

Example

Do you know how to get this result? If you have an idea, can you focus on the following points?

  • Create a gradient inside each circle
  • Create a shadow on the head of the circle

Thank you in advance.

+3
source share
2 answers

Check your user control, I tried to bring it as close as possible to the design of the Activity application, and everything is configured.

https://github.com/maxkonovalov/MKRingProgressView


The basic idea of ​​the algorithm is quite simple.

:

Conical gradient

Photoshop . : https://github.com/maxkonovalov/MKGradientView.

Cropped gradient

CGContextSaveGState(ctx)
CGContextAddPath(ctx, arcPath)
CGContextClip(ctx)
CGContextDrawImage(ctx, gradientRect, gradientImage)
CGContextRestoreGState(ctx)

:

  • ( 50%)

Shadow

, .

CGContextSetShadow(ctx, offset, shadowRadius)
CGContextAddPath(ctx, shadowPath)
CGContextSetFillColorWithColor(ctx, shadowColor)
CGContextFillPath(ctx)

Shadow clipped

CGContextSaveGState(ctx)
CGContextAddPath(ctx, circlePath)
CGContextClip(ctx)
// Draw shadow...
CGContextRestoreGState(ctx)

:

View cycle progress

+7

All Articles