how to load image from local path ios swift (by path)

后端 未结 8 1633
长情又很酷
长情又很酷 2020-12-04 20:02

In my app I am storing an image in local storage and I am saving the path of that image in my database. How can I load the image from that path?

Here is the code I a

8条回答
  •  無奈伤痛
    2020-12-04 20:53

    Swift 4:

    if FileManager.default.fileExists(atPath: imageUrlPath) {
                let url = NSURL(string: imageUrlPath)
                let data = NSData(contentsOf: url! as URL)
    
                chapterImage.image = UIImage(data: data! as Data)
            }
    

提交回复
热议问题