title: CAShapeLayer is appearing before Views
body: <p>I have two views between which is located resizable line (view with CAShapeLayer). The problem that I'm facing with is that despite the animation on layer, it is appearing faster than views are changing. I know that animation of layer is completely different, but can't understand where is my fault. Please tell me if I made something wrong.</p>
  
  <p>Here is the code of my layer's animation (used "strokeStart" as well, but it didn't worked):</p>
  
  <pre><code>override func layoutSubviews() {
      super.layoutSubviews()
      let centerX = bounds.size.width / 2
      let path = CGMutablePath()
      path.addLines(between: [CGPoint(x: centerX, y: 0), CGPoint(x: centerX, y: frame.height)])
      dashedLayer.path = path
      dashedLayer.frame = bounds
  
      let animation = CABasicAnimation(keyPath: "strokeEnd")
      animation.fromValue = height
      animation.toValue = bounds.size.height
      height = bounds.size.height
      animation.duration = 0.3
      dashedLayer.add(animation, forKey: nil)
  }
  </code></pre>
  
  <p>Code of views' animation (because of modifying views, I animate layoutIfNeeded):</p>
  
  <pre><code>UIView.animate(withDuration: 0.3, animations: {
      self.view.layoutIfNeeded()
      ...
  </code></pre>