title: Drawing an angle/angular/"Conical"/"Arcing" gradient in Objective-C (IOS) using Core Graphics
body: <p>I'm trying to draw a "conical"/"arcing" gradient (I don't know what would be the correct term for this) <em>(Photoshop calls it an "angle" gradient —your friendly neighborhood stackoverflow editor)</em> using Objective-C (IOS), pretty much exactly like the image shown in the following <a href="https://stackoverflow.com/questions/5379234/how-to-make-a-conical-gradient-in-ios-using-core-graphics-quartz-2d">thread</a>.</p>
  
  <p>After days of googling and searching the internet to no avail, I've decided to ask for help here.</p>
  
  <p>A little background on what I'm trying to do. My objective is to create a custom UIView, which is circular progress bar, a ring basicly, somewhat similar to the activity indicator as seen in the TweetBot iPhone app (displays when you drag to refresh, which can be seen in action <a href="http://www.youtube.com/watch?v=ZBOHGzE6TNY&amp;feature=player_detailpage#t=16s" rel="nofollow noreferrer">here</a>, around 17-18 seconds into the video, on top of the iphone screen). I want the progress indicator (the fill of the ring) to be a simple two color gradient, which can be set programmatically, and the view to be resizable.</p>
  
  <p>Filling the ring shape with a gradient that "follows" the arc of the ring is where I'm stuck. The answers that I get from googling, reading Apple's Core Graphics documentation on gradients and searching on SO are either about radial gradients or linear/axial gradients, which is not what I'm trying to achieve.</p>
  
  <p>The thread linked above suggests using pre-made images, but this isn't an option because the colors of the gradient should be settable, the view should be resizable and the fill of the progress bar isn't always 100% full obviously (which would be the state of the gradient as shown in the picture in the thread above).</p>
  
  <p>The only solution that I've come up with is to draw the gradient "manually", so without using a <code>CGGradientRef</code>, clipping small slices of the gradient with single solid color fills within a circular path. I don't know exactly how well this will perform when the bar is being animated though, it shouldn't be that bad, but it might be a problem.</p>
  
  <p>So my first question:</p>
  
  <p><strong>Is there an easier/different solution to draw a conical/arcing gradient in Objective-C (IOS) than the solution I've come up with?</strong></p>
  
  <p>Second question:</p>
  
  <p><strong>If I have to draw the gradient manually in my view using the solution I came up with, how can I determine or calculate (if this is even possible) the value (HEX or RGBA) of each color "slice" of the gradient that I'm trying to draw, as illustrated in the image below.</strong></p>
  
  <p>(Can't link image) <a href="http://img808.imageshack.us/img808/7419/lijntje.jpg" rel="nofollow noreferrer">gradient slice illustration</a></p>