Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift 5 full screen image viewer

@IBAction func imageTapped(sender: UITapGestureRecognizer) {
    let imageView = sender.view as! UIImageView
    let newImageView = UIImageView(image: imageView.image)
    newImageView.frame = UIScreen.main.bounds
    newImageView.backgroundColor = .blackColor()
    newImageView.contentMode = .ScaleAspectFit
    newImageView.userInteractionEnabled = true
    let tap = UITapGestureRecognizer(target: self, action: "dismissFullscreenImage:")
    newImageView.addGestureRecognizer(tap)
    self.view.addSubview(newImageView)
    self.navigationController?.isNavigationBarHidden = true
    self.tabBarController?.tabBar.isHidden = true
}

func dismissFullscreenImage(sender: UITapGestureRecognizer) {
    self.navigationController?.isNavigationBarHidden = false
    self.tabBarController?.tabBar.isHidden = false
    sender.view?.removeFromSuperview()
}
Comment

swift 5 full screen image viewer

@IBAction func imageTapped(_ sender: UITapGestureRecognizer) {
    let imageView = sender.view as! UIImageView
    let newImageView = UIImageView(image: imageView.image)
    newImageView.frame = UIScreen.main.bounds
    newImageView.backgroundColor = .black
    newImageView.contentMode = .scaleAspectFit
    newImageView.isUserInteractionEnabled = true
    let tap = UITapGestureRecognizer(target: self, action: #selector(dismissFullscreenImage))
    newImageView.addGestureRecognizer(tap)
    self.view.addSubview(newImageView)
    self.navigationController?.isNavigationBarHidden = true
    self.tabBarController?.tabBar.isHidden = true
}

@objc func dismissFullscreenImage(_ sender: UITapGestureRecognizer) {
    self.navigationController?.isNavigationBarHidden = false
    self.tabBarController?.tabBar.isHidden = false
    sender.view?.removeFromSuperview()
}
Comment

PREVIOUS NEXT
Code Example
Swift :: uicolor gray 
Swift :: selector cannot call in notification observer swift 
Swift :: convert dictionary to data 
Swift :: Named Associated Values Swift 
Swift :: get files with file type swift 
Swift :: swift function return type 
Swift :: Example: Nested Tuple 
Swift :: Swift Code Blocks 
Swift :: where to save audio asset swift 
Swift :: Compare AnyObjects en Swift 
Swift :: detect textfield change swiftui 
Swift :: .next() enum swift 
Ruby :: ruby file extension 
Ruby :: ruby get current datetime 
Ruby :: rails trackable to devise 
Ruby :: How can I rename a database column in a Ruby on Rails migration? 
Ruby :: ruby replace first character in string 
Ruby :: post request rails link_to 
Ruby :: how to force exit server in rails 
Ruby :: rails reset database 
Ruby :: parse xml ruby 
Ruby :: ruby reverse string 
Ruby :: ruby is character 
Ruby :: rails convert unix timestamp to datetime 
Ruby :: how to call ruby private methods 
Ruby :: jupyter notebook ruby 
Ruby :: rails retrieve database.yml 
Ruby :: rails image url from console 
Ruby :: ruby for programmers 
Ruby :: unlocking all the artifacts 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =