Hi, I'm trying to make it so that when you touch a map in one of my views, the map occupies the entire screen and with another touch it shrinks to its original size without it disappearing.
This is the structure of my views:
And when executing the following code:
override func viewDidLoad() {
super.viewDidLoad()
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(VistaDetalleNivelUnoVC.ModifySize))
mapLocation.addGestureRecognizer(tap)
}
func dismissFullscreenImage(sender: UITapGestureRecognizer) {
sender.view?.removeFromSuperview()
}
func ModifySize () {
print("Full")
let screenSize: CGRect = UIScreen.mainScreen().bounds
let screenWidth = screenSize.width
let screenHeight = screenSize.height
mapLocation.userInteractionEnabled = true
mapLocation.multipleTouchEnabled = true
mapLocation.frame = CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight)
self.view.bringSubviewToFront(mapLocation)
print(mapLocation.frame)
let tap = UITapGestureRecognizer(target: self, action: #selector(VistaDetalleNivelUnoVC.dismissFullscreenImage(_:)))
mapLocation.addGestureRecognizer(tap)
}
When you click on the map it looks like this:
and when I tap on it again it disappears completely:
How can I make the map occupy the whole screen in front of the other view that contains the UIImageView and how can I return it to its original size with a single touch.
If you do this you will always delete the map
What you need is to resize the map again not delete it from the superview , so just do the same thing you do to make it bigger which is to change its frame