Swift - Write Image from URL to Local File

前端 未结 6 653
一生所求
一生所求 2021-02-01 15:55

I\'ve been learning swift rather quickly, and I\'m trying to develop an OS X application that downloads images.

I\'ve been able to parse the JSON I\'m looking for into a

6条回答
  •  伪装坚强ぢ
    2021-02-01 16:48

    @IBAction func savePhoto(_ sender: Any) {
    
            let imageData = UIImagePNGRepresentation(myImg.image!)
            let compresedImage = UIImage(data: imageData!)
            UIImageWriteToSavedPhotosAlbum(compresedImage!, nil, nil, nil)
    
            let alert = UIAlertController(title: "Saved", message: "Your image has been saved", preferredStyle: .alert)
            let okAction = UIAlertAction(title: "Ok", style: .default)
            alert.addAction(okAction)
            self.present(alert, animated: true)
        }   
    }
    

提交回复
热议问题