LPLivePhotoGenerator 0.7.0

LPLivePhotoGenerator 0.7.0

Oleg Abalonski 维护。



LPLivePhotoGenerator

GitHub release GitHub license CocoaPods

一个用于创建和保存 Live Photos 的 Swift 库

安装

作为 CocoaPods 依赖项

将以下内容添加到您的 Podfile 中

pod 'LPLivePhotoGenerator'

在您的 Podfile 所在的目录中运行 cd 并安装

pod install

手动安装(框架)

  1. LPLivePhotoGenerator.xcodeproj 文件拖入您的 Xcode 项目。
  2. 在目标 "General" 选项卡中,将 LPLivePhotoGenerator.framework 添加到 "Embedded Binaries"。

用法

1. 导入 LPLivePhotoGenerator

在任何需要使用 LPLivePhotoGenerator 的地方导入该模块

import LPLivePhotoGenerator

2. 创建并保存动图照片

// Create a LivePhoto object with a image path and video path
LPLivePhotoGenerator.create(inputImagePath: imagePath, inputVideoPath: videoPath) { (livePhoto: LPLivePhoto?, error: Error?) in

    // Unwrap object
    if let livePhoto = livePhoto {

        // Set the Live Photo in a PHLivePhotoView
        let livePhotoView = PHLivePhotoView(frame: rect)
        livePhotoView.livePhoto = livePhoto

        // Save Live Photo to Photo Library
        livePhoto.writeToPhotoLibrary(completion: { (livePhoto: LPLivePhoto, error: Error?) in

          if error == nil {
            ...
          }
        })
    }
}

3. 额外工具(LPLivePhoto 方法)

// Move paired image and video to new path
livePhoto.movePairedImageAndVideoTo(path: path, completion: { (success: Bool, error: Error?) in

    if success {
        ...
    }
})

演示应用程序

“演示”是一个基本的参考应用程序,用于展示如何使用 CocoaPods 安装 LPLivePhotoGenerator 并使用该库开发应用程序。

安装

在继续之前应安装 CocoaPods。要访问项目,请运行以下命令:

git clone --recursive https://github.com/OlegAba/LPLivePhotoGenerator.git
cd LPLivePhotoGenerator/Demo/
pod install
open Demo.xcworkspace

您还可以查看 SuperSnapcode - 一个使用此库构建的开源 iOS 应用程序

许可

本项目受 MIT 许可证的许可 - 有关详细信息,请参阅 LICENSE 文件