title: Swift - Set label to be on top of other view items
body: <p>I'm creating a basic sketching app using swift 1.2 and Xcode 6.4. The feature I'm working on is adding text to the image for future manipulation.</p>
  
  <p>So far I have the text the user enters adding to the drawing via label, but it is being placed (I assume) behind the <code>UIImage</code> that is to be drawn upon. This is preventing the associated tap gesture from being recognised. The label is also obscured when drawn over.</p>
  
  <p>How do I place the label on top of everything else to prevent it being drawn over? The end goal is to allow the user to move the label.</p>
  
  <p>If I was using my usual web stack I'd set the <code>z-index</code> of the element to a high value via CSS.</p>
  
  <p>Edit: Using <code>view.bringSubviewToFront(label)</code> prevents the text from being drawn over, but does not allow the tap gesture to be picked up.</p>
  
  <p>Heres my code:</p>
  
  <pre><code>    func printText(){
          println(textString)
  
          var label = UILabel(frame: CGRectMake(5, 100, 200, 50 ))
          label.textAlignment = NSTextAlignment.Center
          label.text = textString;
  
          let tap = UITapGestureRecognizer(target: self, action: Selector("handleTap"))
          label.addGestureRecognizer(tap)
  
          self.view.addSubview(label);
      }
  
      func handleTap() {
          print("tap working")
      }
  </code></pre>
  
  <p>Any help much appreciated.</p>