title: Set corners of UIView (iOS)
body: <p>I have the following problem: I'm scanning a QR Code with AVFoundation. This works quite well and I can also create a border around the code by adding a subview and set the <code>frame</code> attribute by <code>subview.frame = qrCodeObject.bounds</code>. This only has the problem that the border is only a rectangle and dismisses the perspective of the QR code.</p>
  
  <p>I know that the qrCodeObject has a property <code>corners</code> which incorporates the top right, top left, bottom right and bottom left points of the QR code detected.</p>
  
  <p>My question is now: how can I apply those corner points to the "border" view to make this border to have the same perspective as the QR code? Or in other words: how to "transform" the view according to the corner points?</p>
  
  <p>Thanks a lot in advance!</p>
  
  <p><strong>UPDATE:</strong>
  Here you can see the problem: the red box is a UIView, having it's <code>frame</code> property set to the QR codes <code>bounds</code> property. This misses perspective. I would like to transform the UIView (the red box) to following the <code>corners</code> property of the QR code, which includes the top right, top left, bottom right and bottom left points (<code>CGPoint</code>) of the QR code. It is important to apply this to a UIView, because I later want to apply it to an ImageView. Also a mask is not usable, as it just hides part of the view, but does not stretch or transform the content of the view.</p>
  
  <p><a href="https://i.stack.imgur.com/PzQz7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PzQz7.png" alt="QR code and box"></a></p>