title: iOS How can I draw small circle limit in the big circle in movement
body: <p>I want to achieve the effect shown in <a href="https://github.com/MitrophD/Swift-SpriteKit-Analog-Stick" rel="nofollow noreferrer">this github project</a>, but I don't want to use SpriteKit to achieve this.</p>
  
  <p><img src="https://i.stack.imgur.com/LUPJv.png" alt="enter image description here"></p>
  
  <p>So I try to draw the big circle in the CircleViiew.m about the CGContextRef in Objective-C.</p>
  
  <pre><code> #import "CircleView.h"
   #import &lt;QuartzCore/QuartzCore.h&gt;
   #define CIRCLE_RADIUS  80
  
   @implementation CircleView
   -(id) initWithFrame:(CGRect)frame andCircleRadius:(int) radius
   {
       self = [super initWithFrame:frame];
       if(self)
       {   
       }
       return self;
   }
  
   - (void)drawRect:(CGRect)rect {
  
       CGContextRef context = UIGraphicsGetCurrentContext();
  
       // set rect background color
       CGRect drawRect = CGRectMake(rect.origin.x, rect.origin.y,rect.size.width, rect.size.height);
       CGContextSetRGBFillColor(context, 100.0f/255.0f, 100.0f/255.0f, 100.0f/255.0f, 1.0f);
       CGContextFillRect(context, drawRect);
  
       // set line border number
       CGContextSetRGBStrokeColor(context,0.6,1,0.6,1.0);
       CGContextSetLineWidth(context, 2.0);
       CGContextAddArc(context, 82, 82, CIRCLE_RADIUS, 0, 2*M_PI, 0);
       CGContextDrawPath(context, kCGPathStroke);
  
  // fill color
       UIColor *fillCircleColor = [UIColor colorWithRed:1.000 green:0.800 blue:0.000 alpha:1.000];
       CGContextSetFillColorWithColor(context, fillCircleColor.CGColor);
       CGContextAddArc(context, 82, 82, CIRCLE_RADIUS, 0, 2*M_PI, 0);
       CGContextDrawPath(context, kCGPathFill);
  
       CGContextDrawPath(context, kCGPathFillStroke);   
  
   }
   @end
  </code></pre>
  
  <p>Then in the ViewController using the circle.</p>
  
  <pre><code>  CircleView *circle = [[CircleView alloc] initWithFrame:CGRectMake(20, 20, 164, 164)];
       [self.view addSubview:circle];
  </code></pre>
  
  <p>But I don't know how to add the small circle overlay the big circle, and the small have to limit on the big circle when we movement the small circle.</p>
  
  <p>Is create small circle object using CircleView on the viewDidload to overlay BigCircle? Or the small circle have to draw in the CircleView class?</p>
  
  <p>I am using auto layout to create the effect. I don't know if I use <code>initwithFrame</code> to make, have generate problem after.</p>
  
  <p>Can anyone give me some direction?</p>