How to rotate a circle(drawn through core graphics) clockwise and anticlockwise?
<p>This is my code.I want to rotate my circle clockwise and anticlockwise.if anyone knows how to do it for a circle drawn with core graphics' please guide me how to do it.</p>

<pre><code>- (void)drawRect:(CGRect)rect { 

    CGContextRef context = UIGraphicsGetCurrentContext();
    mainSquare = CGRectMake(X_SPACE, Y_SPACE, 220, 200);
    CGContextSaveGState(context);

    // Create circle path and clip
    CGContextAddEllipseInRect(context, mainSquare);
    CGContextClip(context);

    // Define rects
    NSLog(@"helll  %f",mainSquare.size.width);
     CGRect topLeft = CGRectMake(mainSquare.origin.x, mainSquare.origin.y, (mainSquare.size.width / 2) , (mainSquare.size.height / 2) );
     CGRect topRight = CGRectMake((mainSquare.size.width / 2) + X_SPACE, mainSquare.origin.y, mainSquare.size.width / 2, (mainSquare.size.height / 2) );
     CGRect bottomLeft = CGRectMake(mainSquare.origin.x, (mainSquare.size.height / 2) + Y_SPACE, mainSquare.size.width / 2, (mainSquare.size.height / 2) );
     CGRect bottomRight = CGRectMake((mainSquare.size.width / 2) + X_SPACE, (mainSquare.size.height / 2) + Y_SPACE, mainSquare.size.width / 2, mainSquare.size.height / 2);  

    // Define colors
    CGColorRef topLeftColor = [[UIColor redColor] CGColor];
    CGColorRef topRightColor = [[UIColor blueColor] CGColor];
    CGColorRef bottomLeftColor = [[UIColor greenColor] CGColor];
    CGColorRef bottomRightColor = [[UIColor yellowColor] CGColor];

    // Fill rects with colors
    CGContextSetFillColorWithColor(context, topLeftColor);
    CGContextFillRect(context, topLeft);

    CGContextSetFillColorWithColor(context, topRightColor);
    CGContextFillRect(context, topRight);

    CGContextSetFillColorWithColor(context, bottomLeftColor);
    CGContextFillRect(context, bottomLeft);

    CGContextSetFillColorWithColor(context, bottomRightColor);
    CGContextFillRect(context, bottomRight);


    CGContextRestoreGState(context);

}


 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

     [super touchesBegan:touches withEvent:event];
     UITouch *touch = [[event allTouches] anyObject]; 
     swipeBackward = [touch locationInView: [touch view]]; 
 }

 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

     [super touchesEnded:touches withEvent:event]; 
     UITouch *touch = [[event allTouches] anyObject]; 
     swipeForward = [touch locationInView: [touch view]]; 

     double dx = swipeBackward.x - swipeForward.x;
    // double dy = swipeBackward.y - swipeForward.y;     

     if( (swipeBackward.x &lt; 160) &amp;&amp; (swipeForward.x &lt; 160) &amp;&amp; (swipeBackward.y &lt;= 151) &amp;&amp; (swipeForward.y &gt; 151) ) 
     {  
             NSLog(@"Rotate Anticlockwise");
             mainSquare.transform = CGAffineTransformMakeRotation(63.0*radianConst);

     }  

     else if( (swipeBackward.x &lt; 160) &amp;&amp; (swipeForward.x &lt; 160) &amp;&amp; (swipeBackward.y &gt;= 151) &amp;&amp; (swipeForward.y &lt; 151) )
     {
             NSLog(@"Rotate Clockwise");

     }

     else if( (swipeBackward.x &gt; 160) &amp;&amp; (swipeForward.x &gt; 160) &amp;&amp; (swipeBackward.y &lt;= 151) &amp;&amp; (swipeForward.y &gt; 151) ) 
     {          
            NSLog(@"Rotate Clockwise"); 

     }  

     else if( (swipeBackward.x &gt; 160) &amp;&amp; (swipeForward.x &gt; 160) &amp;&amp;  (swipeBackward.y &gt;= 151) &amp;&amp; (swipeForward.y &lt; 151) )
     {
             NSLog(@"Rotate Anticlockwise");             

     }

     else if( (swipeBackward.y &gt; 151) &amp;&amp; (swipeForward.y &gt; 151) ) 
     { 
         if (dx &gt; 0 ) 
         {
             NSLog(@"Rotate Clockwise");

         }  

         else 
         {
             NSLog(@"Rotate Anticlockwise");


         }

     }
     else
     { 
         if (dx &gt; 0 ) 
         {
             NSLog(@"Rotate Anticlockwise");


         }  

         else 
         {
             NSLog(@"Rotate Clockwise");


         }

     }


}
</code></pre>
