title: Drawing a circle after button click in xcode
body: <p>I am trying to draw a circle after clicking a button. I can create a rectangle but cannot draw a circle.</p>
  
  <p>Is there a way to make this:</p>
  
  <pre><code>-(IBAction) buttonTouched 
  {
  }
  </code></pre>
  
  <p>call or signal this to work:</p>
  
  <pre><code>- (void)drawRect:(CGRect)rect 
  { 
  }
  </code></pre>
  
  <p>Thanks for any input!</p>
  
  <p><em><strong></em>*Edit*<em>*</em></strong>
  Sorry, it's not working. Not sure what I'm doing wrong:</p>
  
  <p>1) Created a new view-based project named "test".
  2) Created a Objective-C class UIView named "view".
  3) In IB dragged a button onto the view, linked it to "buttonTouched" - Touched Up Inside.</p>
  
  <pre><code>testViewController.h
  #import &lt;UIKit/UIKit.h&gt;
  #import "view.h"
  @interface testViewController : UIViewController {
  }
  -(IBAction) buttonTouched;
  @end
  
  
  testViewController.m
  #import "testViewController.h"
  #import "view.h"
  @implementation testViewController
  - (IBAction)buttonTouched {
      [[self view] setNeedsDisplay];
  }
  
  view.m
  
  #import "view.h"
  
  @implementation view
  
  - (id)initWithFrame:(CGRect)frame {    
     self = [super initWithFrame:frame];
      if (self) {
      }
      return self;
  }
  
  - (void)drawRect:(CGRect)rect {
      CGContextRef contextRef = UIGraphicsGetCurrentContext();
  
      CGContextFillEllipseInRect(contextRef, CGRectMake(100, 100, 25, 25));
      CGContextSetRGBFillColor(contextRef, 0, 0, 255, 1.0);
  
      CGContextStrokeEllipseInRect(contextRef, CGRectMake(100, 100, 25, 25));
      CGContextSetRGBFillColor(contextRef, 0, 0, 255, 1.0);
  }
  
  
  - (void)dealloc {
      [super dealloc];
  }
  
  @end
  </code></pre>