Photos(PHLivePhoto)
PhotosUI(PHLivePhotoView)
PHLivePhotoView用于显示用户的生活照片。
public var livePhoto: PHLivePhoto?
/// 是否有声音
public var muted: Bool
/// 控制回放的手势
public var playbackGestureRecognizer: UIGestureRecognizer { get }
/// 开始播放生活照片
public func startPlaybackWithStyle(playbackStyle: PHLivePhotoViewPlaybackStyle)
/// 停止播放
public func stopPlayback()
/// 代理,监听播放开始和结束
weak public var delegate: PHLivePhotoViewDelegate?
/// 获取显示照片
///
/// - parameter badgeOptions : PHLivePhotoBadgeOptions
///
/// - returns: UIImage
public class func livePhotoBadgeImageWithOptions(badgeOptions: PHLivePhotoBadgeOptions) -> UIImage
下面演示了显示并播放生活照片的源代码
if self.asset.mediaSubtypes == PHAssetMediaSubtype.PhotoLive {
let options = PHLivePhotoRequestOptions()
options.deliveryMode = PHImageRequestOptionsDeliveryMode.HighQualityFormat
options.networkAccessAllowed = true
options.progressHandler = { (progress: Double, error: NSError?, stop: UnsafeMutablePointer<ObjCBool>, info: [NSObject : AnyObject]?) -> Void in
print(progress)
}
PHImageManager.defaultManager().requestLivePhotoForAsset(self.asset, targetSize: self.targetSize(), contentMode: PHImageContentMode.AspectFit, options: options, resultHandler: { (livePhoto: PHLivePhoto?, info: [NSObject : AnyObject]?) -> Void in
self.livePhotoView.livePhoto = livePhoto
if let degradedKeyinfo = info?[PHImageResultIsDegradedKey] {
if !degradedKeyinfo.boolValue && !self.playing {
self.livePhotoView.startPlaybackWithStyle(PHLivePhotoViewPlaybackStyle.Hint)
}
}
})
}
Swift
Photos Framework Reference
PHLivePhoto Class Reference
时间 | 描述 |
---|---|
2016-01-07 | 博文完成 |
CSDN:http://blog.csdn.net/y550918116j
GitHub:https://github.com/937447974/Blog