-1

I am trying to load a live image into a UImageView but it is being loaded as a static image.

Here is my code:

if let stringLocal = Bundle.main.path(forResource: "Image_from _iOS", ofType: "jpg") {
    self.displayImageView.image = UIImage(named: stringLocal)
}

Any suggestions?

shim
  • 9,289
  • 12
  • 69
  • 108
osxDev123
  • 21
  • 4

2 Answers2

1

You need to use PHLivePhoto instead of UIImageView.

Specifically for loading you need to use this method

request(withResourceFileURLs:placeholderImage:targetSize:contentMode:resultHandler:)

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Enrique Bermúdez
  • 1,740
  • 2
  • 11
  • 25
  • 1
    Also the format in the question is jpg. Pretty sure jpg doesn't contain the live photo data; would need to use HEIC. – shim Jan 25 '19 at 16:06
  • is there any site where live wallpapers i can find, so that i can pull in into my app to show users. – osxDev123 Jan 28 '19 at 05:34
1

A live photo is a PHLivePhoto, not a UIImage. So it is displayed live in a PHLivePhotoView, not a UIImageView.

matt
  • 515,959
  • 87
  • 875
  • 1,141