text: Q:
  
  Circle UIView resize with animation keeping Circle shape
  
  I have a UIView which I am making the background a circular shape with:
   self.colourView.layer.cornerRadius = 350
   self.colourView.clipsToBounds = true
  
  With the view being a 700 by 700 square.
  I am then trying to change the size of this view using:
  UIView.animate(withDuration: zoomLength,
                                     delay: 0,
                                     options: .curveEaseIn,
                                     animations: {
                                      self.colorViewWidth.constant = 100
                                      self.colorViewHeight.constant = 100
  
                                      self.colourView.layer.cornerRadius = 50
                                      self.colourView.clipsToBounds = true
                                      self.view.layoutIfNeeded()
                                      },
                                     completion: { finished in
  
                                          })
  
                                      })
  
  The problem with this is the corner radius of the view switch to 50 instantly. So that as the view shrinks in size it doesn't look like a circle shrinking but a square with rounded corners until it reaches the 100 by 100 size.
  How can I take a view that circule in shape and shrink it down while maintaining the circlare shape during the animation.
  
  A:
  
  You could always animate the corner radius as well with a CABasicAnimation along side the UIView animations.  See example below.
  import UIKit
  
  class ViewController: UIViewController {
  
      //cause 'merica
      var colorView = UIView()
      var button = UIButton()
  
      var colorViewWidth : NSLayoutConstraint!
      var colorViewHeight : NSLayoutConstraint!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
  
          colorView.frame = CGRect(x: 0, y: 0, width: 750, height: 750)
          colorView.center = self.view.center
          colorView.backgroundColor = .blue
          colorView.layer.cornerRadius = 350
          colorView.clipsToBounds = true
          colorView.layer.allowsEdgeAntialiasing = true
          colorView.translatesAutoresizingMaskIntoConstraints = false
  
          //set up constraints
  
          colorViewWidth = NSLayoutConstraint(item: colorView, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 750)
          colorViewWidth.isActive = true
  
          colorViewHeight = NSLayoutConstraint(item: colorView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 750)
          colorViewHeight.isActive = true
  
          self.view.addSubview(colorView)
          colorView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
          colorView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
  
          //button for action
          button = UIButton(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width - 20, height: 50))
          button.center = self.view.center
          button.center.y = self.view.bounds.height - 70
          button.addTarget(self, action: #selector(ViewController.pressed(sender:)), for: .touchUpInside)
          button.setTitle("Animate", for: .normal)
          button.setTitleColor(.blue, for: .normal)
  
          self.view.addSubview(button)
  
      }
  
      func pressed(sender:UIButton) {
  
          self.colorViewWidth.constant = 100
          self.colorViewHeight.constant = 100
  
          UIView.animate(withDuration: 1.0,
                         delay: 0,
                         options: .curveEaseIn,
                         animations: {
                          self.view.layoutIfNeeded()
  
          },
  
                         completion: { finished in
  
          })
  
          //animate cornerRadius and update model
          let animation = CABasicAnimation(keyPath: "cornerRadius")
          animation.duration = 1.0
          //super important must match
          animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
          animation.fromValue = colorView.layer.cornerRadius
          animation.toValue = 50
          colorView.layer.add(animation, forKey: nil)
          //update model important
          colorView.layer.cornerRadius = 50
  
      }
  }
  
  Result:
  
  