Hey guys. Here is what I am trying to do:
Ive created and UIImageView that displays an image.
Ive created an UILabel (3/4 size of the image)
When I tap an image, Id like that UILabel to cover part of that image.
Any clues how to do that? Ive tried addTapGestureRecognizer but Im not sure how to do it in a best way. Any help appreciated.
Ive seen some documentation but I don't not understand how to use those informations in practise.
Ive created and UIImageView that displays an image.
Ive created an UILabel (3/4 size of the image)
When I tap an image, Id like that UILabel to cover part of that image.
Any clues how to do that? Ive tried addTapGestureRecognizer but Im not sure how to do it in a best way. Any help appreciated.
Ive seen some documentation but I don't not understand how to use those informations in practise.
Could you show the code you've written so far ?
A simple way would be:
now the label is over the image
If that works, don't forget to close the thread by marking correct answer.
A simple way would be:
make sure the label is over image (in the hierarchy point of view) so that it will not be hidden behind image
create constraint for position of label with respect to UIImage
create an IBOutlet for the constraint
Code Block @IBOutlet weak var labelToImageTopConstraint: NSLayoutConstraint!
in viewDidLoad, adjust so that label is below image
Code Block labelToImageTopConstraint.constant = image.frame.height + 10 // To have the label just below the image
in the tapGesture handler, adjust the contraint constant
Code Block labelToImageTopConstraint.constant = 10
now the label is over the image
If that works, don't forget to close the thread by marking correct answer.