title: while using CGAffineTransform view size is different while clicking
body: <p><a href="https://i.stack.imgur.com/SnBM4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SnBM4.png" alt="enter image description here"></a>i want to add animation while clicking the view. while displaying first time its circle but when i Transform the view size changes. i was want to add animation while change background animation show be like change circle from center to its end of view.
  my code </p>
  
  <pre><code>class ClickableView: UIControl {
    @IBInspectable public var selectedColor: UIColor = UIColor.clear{
      didSet{
        updateColor()
      }
    }
    override open var isSelected: Bool{
      didSet{
        UIView.animate(withDuration: 0.2, animations: {
          self.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
        }) { (finished) in
          UIView.animate(withDuration: 0.3, animations: {
            self.transform = CGAffineTransform.identity
          })
        }
        updateLayout()
        updateColor()
      }
    }
    @IBInspectable public var mainColor: UIColor = UIColor.white{
      didSet{
        updateColor()
      }
    }
  
    // MARK: - initializers
    override init(frame: CGRect) {
      super.init(frame: frame)
      addAction()
    }
    required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
      addAction()
    }
    func updateLayout(){
      self.layer.cornerRadius =  self.frame.size.width/2
      self.layer.masksToBounds = true
      self.layer.borderWidth = 10
      self.layer.borderColor = UIColor.gray.cgColor
  
    }
    // MARK: - draw rect
    override func draw(_ rect: CGRect) {
      super.draw(rect)
      updateLayout()
    }
    @objc func touchUpInside(){
      self.isSelected = isSelected == true ? false:true
    }
    func addAction()  {
      self.addTarget(self, action: #selector(touchUpInside), for: .touchUpInside)
    }
  
    private func updateColor(){
  
      UIView.animate(withDuration: 0.3) { [weak self] in
        guard let strongSelf = self else{return}
        strongSelf.backgroundColor = strongSelf.isSelected == true ? strongSelf.selectedColor:strongSelf.mainColor
      }
  
    }
  
  
  }
  </code></pre>