I have the following ViewController
class I am trying to get to display a live photo. I am not precisely sure how to actually get the image to show In dealing with a UIImageView I would write something like this:
let image = UIImage(imageNamed: "someStringPointingToImage") //then add this to the image view.
But does anyone know how it works with a live image that I have added in my assets?
The function
import UIKit
import Photos;
import PhotosUI
import MobileCoreServices
class ViewController: UIViewController, PHLivePhotoViewDelegate {
var livePhotoIsAnimating = Bool()
override func viewDidLoad() {
super.viewDidLoad()
self.livePhotoView()
}
//MARK: Create the Live Photoview
func livePhotoView() {
let photoView: PHLivePhotoView = PHLivePhotoView.init(frame: self.view.bounds)
//%%%%%%% Area to add the image %%%%%%
photoView.contentMode = .ScaleAspectFill
self.view.addSubview(photoView)
self.view.sendSubviewToBack(photoView)
}
func livePhotoView(livePhotoView: PHLivePhotoView, willBeginPlaybackWithStyle playbackStyle: PHLivePhotoViewPlaybackStyle) {
self.livePhotoIsAnimating = true
}
func livePhotoView(livePhotoView: PHLivePhotoView, didEndPlaybackWithStyle playbackStyle: PHLivePhotoViewPlaybackStyle) {
self.livePhotoIsAnimating = false
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Thanks.