title: How to draw polygons in cocoa touch using UIBezierPath
body: <p>I want to draw polygon of different sides (4-12). What is the logic for drawing a polygon. For e.g. if user selects 6 side, it should draw a hexagon, if user enters 8 sides it should draw a octagon. I have found the following code but i also want to resize the UIView in which i am drawing a polygon so that the shape inside of the view also grows along with the view. Any body can help me please. Following is the code i am using currently but it is not positioned at the center also when i resize the view that shape moves to another position in the view.</p>
  
  <pre><code>    int radius = MINIMUM(widht, height)*0.4 ;
  
       for (int i = 0; i &lt; _numberOFsides; i++){
  
              CGPoint point = CGPointMake(widht/2+radius *cosf(i*2*M_PI/_numberOFsides), widht/2+radius*sinf(i*2*M_PI/_numberOFsides));
  
              if (i==0) {
  
                  [_shapePath moveToPoint:point];
  
              }
              else{
                  [_shapePath addLineToPoint:point];
  
                  [_shapePath stroke];
              }
  
          }
  </code></pre>