I'm trying to draw a "conical" / "arc" gradient (I don't know what the correct term would be for this) (Photoshop calls it the gradient "angle" - your friendly stackoverflow editor in the neighborhood) using Objective-C (IOS), in precision like the image shown in the following.
After several days of searching the Internet and searching the Internet to no avail, I decided to seek help here.
A little bit about what I'm trying to do. My goal is to create a custom UIView that is a circular progress bar, the ring basically looks like an activity bar, as shown in the iPhone TweetBot application (displayed when dragging and dropping to update, which can be seen in action here , about 17-18 seconds in the video over the iphone screen). I want the progress indicator (filling the ring) to be a simple two-color gradient that can be set programmatically and the presentation can be changed.
Filling the shape of the ring with the gradient that follows, the arc of the ring is where I get stuck. The answers I get from googling, reading the Apple Core Graphics documentation on gradients, and searching on SO are either radial gradients or linear / axial gradients, which I am not trying to achieve.
The thread-related tooltip assumes the use of pre-made images, but this is not an option, since the gradient colors must be customizable, the presentation must be mutable, and the progress bar fill is not always 100% full (this will be the state of the gradient, as shown in the figure above).
The only solution I came up with is to draw the gradient “manually”, so without using CGGradientRef clipping small fragments of the gradient with one solid color are filled in a circular path. I don’t know exactly how well this will work when the panel is animated, but it should not be so bad, but it can be a problem.
So my first question is:
Is there a simpler / different solution for drawing a conical / arc gradient in Objective-C (IOS) than the solution I came up with?
Second question:
If I need to manually draw a gradient in my view using a solution that I came up with, how can I determine or calculate (if possible) the value (HEX or RGBA) of each color “slice” of the gradient that I am trying to do, as shown in image below.
(Unable to link image) Gradient slice illustration