Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make UILabel appear on top of UIImageView in storyboard

I want to make the a label appear over an image view. But when I place the label over it it disappears. Whats the best way around this?

I have a couple of labels over my image view. When I build and run it the labels appear fine. But on the storyboard when I place ui items such as a label over my image view it doesn't show. How can I make this show

Image

As seen on the screen shot I can't see my labels It appears when I build and run but on the story board the image view hides it this is still a problem.

like image 546
Dan A Avatar asked Jan 24 '16 06:01

Dan A


2 Answers

In a story board, if you place the label on top of the image view it will appear that way. Just make sure that you have the proper constraints on both the image view and the label so that they would be on top of each other and it should work. To answer your question, putting a label on top of an image view does not make it disappear.

This would put the label in front of the image view:

This would put the label in front of the imageview

and this would put it behind the imageview

and this would put it behind the imageview

Just replace the order from the side menu in storyboard. Put it below the image view and it will be on top

like image 162
Unis Barakat Avatar answered Nov 14 '22 23:11

Unis Barakat


The method has been updated since swift 3

What has worked for me and hopefully for you is using :

YourView.bringSubview(toFront: yourelementA)
YourView.bringSubview(toFront: yourelementB)

Alternatively you could use the following to send the object that is in the front:

YourView.sendSubview(toBack: yourelementC)
like image 22
K-A Avatar answered Nov 14 '22 23:11

K-A