Reputation: 5839
This is actually a follow up to this question - How can I display image on fullscreen when user taps on my UIImage in Swift?
I managed to add a tap listener to my uiimageview, but now I would like to expand it when user clicks it. I have an iboutlet for that photo:
@IBOutlet weak var requestPhoto: UIImageView!
and then the listener so far prints this string:
func tapHandler(sender: UITapGestureRecognizer) {
if sender.state == .Ended {
print("photo tapped")
}
}
Now instead of printing the string I want to show the photo on the full screen, but so that it could work on any size of the iphone screens - is there a way of doing that directly from the code?
Upvotes: 0
Views: 1802
Reputation: 539
Upvotes: 0
Reputation: 8006
Quite easily :
self.requestPhoto.frame = self.view.frame
Bear in mind though, that this will not adjust after rotating the screen. If you support both portrait and landscape it would be best to get outlest for constraints and manipulate them.
Also this method will preserve navigation and tab bars (the photo won't cover them). If you want "full" fullscreen, you should take the frame of UIWindow
Upvotes: 1