Ich habe die folgenden ViewController
Klasse Ich versuche, ein Live-Foto anzuzeigen. Ich bin nicht genau sicher, wie man tatsächlich das Bild bekommen zu zeigen, mit einem UIImageView Im Umgang würde ich so etwas schreiben:Anzeige eines Live-Fotos, swift
let image = UIImage(imageNamed: "someStringPointingToImage") //then add this to the image view.
Aber weiß jemand, wie es mit einem Live-Bild arbeitet, die ich in meinem Vermögen hinzugefügt habe ?
Die Funktion
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.
}
}
Dank.
Wenn in Asset, einfach seinen Namen verwenden ... –
Was meinst du mit leben? – Gruntcakes