title: Problems rotating UIView with drawing inside
body: <p>I want to rotate a UIView with a drawing inside (circle, rectangle or line). The problem is when I rotate the view and refresh the drawing (I need ir when I change some properties of the drawing, i.e) the drawing doesn't follow the view...</p>
  
  <p><strong>UIView without rotation:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/UeLZHm.png" alt="UIView without rotation"></p>
  
  <p><strong>UIView with rotation:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/MZsddm.png" alt="UIView rotated and drawing distortion"></p>
  
  <p>Here is my simple code (little extract from the original code):</p>
  
  <p>Main ViewController</p>
  
  <pre><code>class TestRotation: UIViewController {
  
  // MARK: - Properties
  
  var drawingView:DrawingView?
  
  // MARK: - Actions
  
  @IBAction func actionSliderRotation(_ sender: UISlider) {
  
      let degrees = sender.value
      let radians = CGFloat(degrees * Float.pi / 180)
      drawingView?.transform = CGAffineTransform(rotationAngle: radians)
  
      drawingView?.setNeedsDisplay()
  }
  
  // MARK: - Init
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      drawingView = DrawingView(frame:CGRect(x:50, y:50, width: 100, height:75))
  
      self.view.addSubview(drawingView!)
  
      drawingView?.setNeedsDisplay() 
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  }
  </code></pre>
  
  <p>UIView</p>
  
  <pre><code>class DrawingView: UIView {
  
  override func draw(_ rect: CGRect) {
  
      let start = CGPoint(x: 0, y: 0)
      let end = CGPoint(x: self.frame.size.width, y: self.frame.size.height)
  
      drawCicrle(start: start, end: end)
  }
  
  func drawCicrle(start:CGPoint, end:CGPoint) {
  
      //Contexto
      let context = UIGraphicsGetCurrentContext()
  
      if context != nil {
  
          //Ancho
          context!.setLineWidth(2)
  
          //Color
          context!.setStrokeColor(UIColor.black.cgColor)
          context!.setFillColor(UIColor.orange.cgColor)
  
          let rect = CGRect(origin: start, size: CGSize(width: end.x-start.x, height: end.y-start.y))
  
          let path = UIBezierPath(ovalIn: rect)
  
          path.lineWidth = 2
          path.fill()
          path.stroke()
  
      }
  }
  
  // MARK: - Init
  
  override init(frame: CGRect) {
      super.init(frame: frame)
  
      self.backgroundColor = UIColor.gray
  }
  
  required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
  }
  
  }
  </code></pre>
  
  <p>It seems that the problem is temporally solved if I don't refresh the view after rotating, but if I have to refresh later for some other reason (properties changed), the problem appears again.</p>
  
  <p>What can I do? Thanks in advance</p>