title: Layering transparent images and text on top of a mapView (Swift)
body: <p>I want to put a transparent box on top of a mapView and then some text on top of that.</p>
  
  <p>I can do this treating the image as a button and altering the alpha setting but only the last UILabel I put in place remains black, the rest are muted.</p>
  
  <p>Is this possible with Tags or something or does it have to be done programatically?</p>
  
  <p>Anyway after a couple of hours sleuthing this is a working solution.</p>
  
  <ol>
  <li><p>Declare your layer</p>
  
  <pre><code>@IBOutlet weak var layerView: UIView!
  var myLayer: CALayer {
      return layerView.layer
  }
  </code></pre></li>
  <li><p>Put a UIView on your ViewController and link it to layerView.</p></li>
  <li><p>Create a method/func to display the frame, e.g.</p>
  
  <pre><code>func displayMyFrame() {
       myLayer.frame = CGRectMake(100, 100, 200, 40)
       myLayer.backgroundColor = UIColor.whiteColor().CGColor
       myLayer.borderWidth = 1.0
       myLayer.borderColor = UIColor.redColor().CGColor
       myLayer.shadowOpacity = 0.6
       myLayer.cornerRadius = 5.0
       myLayer.shadowRadius = 10.0
      myLayer.opacity = 0.6
  }
  </code></pre>
  
  <ol start="4">
  <li><p>Put your UILabels on the view and change their tags to 1 (in this example).</p></li>
  <li><p>Call the func in viewDidLoad.</p>
  
  <p>displayMyFrame()
  view.layer.insertSublayer(myLayer, atIndex: 1)</p></li>
  </ol></li>
  </ol>
  
  <p>The atIndex: 1 means that this frame will be put behind the UILabels with a Tag of 1.</p>
  
  <p>This works, hope that it helps.</p>