title: Animate a circle from the center in Swift
body: <p>I have a circle that I'm animating. It works except that the drawing is from the top left.. Can I animate it from the center? If so, any help would be appreciated..</p>
  
  <p>My code for drawing the circle is:</p>
  
  <pre><code>class CircleView: UIView {
  
      override func draw(_ rect: CGRect)
          {
              let prefs: UserDefaults = UserDefaults.standard
              lineWidthFloat = prefs.value(forKey: "lineWidth") as! Float
              let circleSize = Double(lineWidthFloat * 100)
              let context = UIGraphicsGetCurrentContext()
              context!.setLineWidth(10.0)
              context!.setFillColor(UIColor.black.cgColor)
              let rect = CGRect(x: 20, y: 20, width: circleSize, height: circleSize)
              context!.addEllipse(inRect: rect)
              context!.fillPath()
          }
  
      }
  </code></pre>
  
  <p>Thanks!</p>