我有下面的ViewController类,我想要显示一张实时照片。我不太清楚如何在处理UIImageView时实际显示图像--我会写这样的东西:
let image = UIImage(imageNamed: "someStringPointingToImage") //then add this to the image view.但是,有人知道我在资产中添加的实时图像是如何工作的吗?
函数
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.
}
}谢谢。
发布于 2016-04-16 20:15:39
Live是Photos应用程序的构造。唯一可以获得Live的地方是Photos框架(而Photos框架则从用户的Photos库获得)。将Live作为捆绑资源存储在应用程序中是不允许的。
如果要显示动画图像,只需使用从一组框架创建动画图像的UIImage构造函数,并在UIImageView中显示它们。添加您自己的手势识别器,您可以很容易地创建一个UI,在默认情况下显示一个静态图像,在点击/按下/任何东西时显示一个动画图像。
如果您想要呈现视频,请查看AVKit。
https://stackoverflow.com/questions/36666701
复制相似问题