Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


UIImage over image view?

Hey guys basically i needed a gif background so i used UIImage and got it working but now when i add a button or a label or anything they are all under the UIImage what shall i do?

 var imageData = NSData(contentsOfURL: NSBundle.mainBundle()
        .URLForResource("desert", withExtension: "gif")!)
    let desert1 = UIImage.animatedImageWithData(imageData!)
    var imageView = UIImageView(image: desert1)
    imageView.frame = CGRect(origin: CGPoint(x: 0, y: 0), size: UIScreen.mainScreen().bounds.size)


1 Answer

Jeroen de Vrind
Jeroen de Vrind
29,772 Points

If you add the imageview in code it will be on top. Have you put your label and button in a xib-file or also in code? If they're all in code put them in the right order or look at the documentation for a uiview method like addSubview: belowView: or addSubview: aboveView: In a xib file you can set the hyrarchie graphically.