title: Swift + Autolayout: Rotate UILabel, keep it next to UIView
body: <p>I would like to have a UILabel attached to another UIView, currently layed out with AutoLayout.</p>
  
  <p>What I would like to achieve is the following:</p>
  
  <p><a href="https://i.stack.imgur.com/tLSUV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tLSUV.png" alt="enter image description here"></a></p>
  
  <p>But if I only rotate the view, it's rotated around the center point, and if I change the anchor point, the upper view moves. How do I have to layout the two views with autolayout first and then make the rotation?</p>
  
  <p>Currently, autolayout does the following:</p>
  
  <p><a href="https://i.stack.imgur.com/UiiLV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UiiLV.png" alt="enter image description here"></a></p>
  
  <p>With the following code:</p>
  
  <pre><code>    label.layer.anchorPoint = CGPoint(x: 0, y: 0)
      label.layer.transform = CATransform3DMakeRotation(CGFloat(-45 / 180.0 * CGFloat(M_PI)), 0, 0, 1)
  </code></pre>
  
  <p>I do get something like</p>
  
  <p><a href="https://i.stack.imgur.com/6yP2K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6yP2K.png" alt="enter image description here"></a></p>