high CPU utilization with custom dial UIControl
<p>Once I used this tutorial <a href="http://www.thinkandbuild.it/building-a-custom-and-designabl-control-in-swift/" rel="nofollow">http://www.thinkandbuild.it/building-a-custom-and-designabl-control-in-swift/</a> for learning about custom controls for iOS Applications. When interacting with the control in the tutorial I notice a very high CPU usage. 
Now I use a similar control for my own application and my drawing functions cause nearly the same CPU usage. I don't even use gradients like in the example code below.</p>

<p>So my question is if I can optimize this in any way or if I should consider myself satisfied with what I can achieve with using the standard drawing methods from apple.</p>

<pre><code>override func drawRect(rect: CGRect){
    super.drawRect(rect)

    let ctx = UIGraphicsGetCurrentContext()


    /** Draw the Background **/

    CGContextAddArc(ctx, CGFloat(self.frame.size.width / 2.0), CGFloat(self.frame.size.height / 2.0), radius, 0, CGFloat(M_PI * 2), 0)
    UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0).set()

    CGContextSetLineWidth(ctx, 72)
    CGContextSetLineCap(ctx, CGLineCap.Butt)

    CGContextDrawPath(ctx, CGPathDrawingMode.Stroke)


    /** Draw the circle **/

    /** Create THE MASK Image **/
    UIGraphicsBeginImageContext(CGSizeMake(self.bounds.size.width,self.bounds.size.height));
    let imageCtx = UIGraphicsGetCurrentContext()
    CGContextAddArc(imageCtx, CGFloat(self.frame.size.width/2)  , CGFloat(self.frame.size.height/2), radius, 0, CGFloat(DegreesToRadians(Double(angle))) , 0);
    UIColor.redColor().set()

    //Use shadow to create the Blur effect
    CGContextSetShadowWithColor(imageCtx, CGSizeMake(0, 0), CGFloat(self.angle/15), UIColor.blackColor().CGColor);

    //define the path
    CGContextSetLineWidth(imageCtx, Config.TB_LINE_WIDTH)
    CGContextDrawPath(imageCtx, CGPathDrawingMode.Stroke)

    //save the context content into the image mask
    let mask:CGImageRef = CGBitmapContextCreateImage(UIGraphicsGetCurrentContext())!;
    UIGraphicsEndImageContext();

    /** Clip Context to the mask **/
    CGContextSaveGState(ctx)

    CGContextClipToMask(ctx, self.bounds, mask)


    /** The Gradient **/

    // Split colors in components (rgba)
    let startColorComps:UnsafePointer&lt;CGFloat&gt; = CGColorGetComponents(startColor.CGColor);
    let endColorComps:UnsafePointer&lt;CGFloat&gt; = CGColorGetComponents(endColor.CGColor);

    let components : [CGFloat] = [
        startColorComps[0], startColorComps[1], startColorComps[2], 1.0,     // Start color
        endColorComps[0], endColorComps[1], endColorComps[2], 1.0      // End color
    ]

    // Setup the gradient
    let baseSpace = CGColorSpaceCreateDeviceRGB()
    let gradient = CGGradientCreateWithColorComponents(baseSpace, components, nil, 2)

    // Gradient direction
    let startPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect))
    let endPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMaxY(rect))

    // Draw the gradient
    CGContextDrawLinearGradient(ctx, gradient, startPoint, endPoint, []);
    CGContextRestoreGState(ctx);

    /* Draw the handle */
    drawTheHandle(ctx!)

}
</code></pre>

<p>The below code describes what I do to draw a handle. It creates simply a gray circle with white bounds.</p>

<pre><code>func drawTheHandle(context: CGContextRef){
    CGContextSaveGState(context)
    handleCenter = pointFromAngle(Int(-angleInt), radius: wheelRadius, center: centerOfCircle)
    grayColor.set();
    CGContextAddArc(context, handleCenter.x, handleCenter.y, handleRadius, 0, 360, 0)
    CGContextDrawPath(context, CGPathDrawingMode.Fill)
    UIColor.whiteColor().set();
    CGContextAddArc(context, handleCenter.x, handleCenter.y, handleRadius, 0, 360, 0)
    CGContextDrawPath(context, CGPathDrawingMode.Stroke)
    CGContextRestoreGState(context);
}
</code></pre>