TakeASelfie
一个使用前置摄像头、检测您的面部并拍照的 iOS 框架。该 API 打开前置摄像头并在屏幕中心绘制绿色椭圆覆盖层。当一个面部被包含在覆盖层中时,自动拍照并保存在相册中。
截图
需求
TakeASelfie 版本 | 最低 iOS 目标 | Swift 版本 |
---|---|---|
0.1.4 | 11.0 | 5.x |
0.1.3 | 11.0 | 4.2 |
0.1.2 | 11.0 | 4.1 |
别忘了给您的应用程序添加权限。
- 隐私 - 相机使用描述(
用于使用相机
) - 隐私 - 相册添加使用描述(
保存捕获的自拍
) - 隐私 - 相册使用描述(可选)(
显示相册中保存的自拍
)
CocoaPods
CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要将TakeASelfie集成到您的Xcode项目中,并使用CocoaPods指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!
target '<Your Target Name>' do
pod 'TakeASelfie', '~>0.1.4'
end
Carthage
Carthage是一种去中心化的依赖关系管理器,它构建您的依赖关系并为您提供二进制框架。
您可以使用以下命令通过Homebrew安装Carthage
brew update
brew install carthage
要使用Carthage将TakeASelfie集成到您的Xcode项目中,请在Cartfile中指定它
github "abdullahselek/TakeASelfie" ~> 0.1.4
Swift Package Manager
修改您的Package.swift
文件,以包含以下依赖关系
.package(url: "https://github.com/abdullahselek/TakeASelfie.git", from: "0.1.4")
运行swift package resolve
用法
首先导入库
import TakeASelfie
.
从SelfieViewDelegate
扩展您的viewcontroller,这样您就可以获取僵尸viewcontroller演绎的事件。
extension MainViewController: SelfieViewDelegate {
func selfieViewControllerDismissed() {
}
}
实例化SelfieViewController
并将其作为模态视图控制器呈现。
let selfieViewController = SelfieViewController(withDelegate: self)
present(selfieViewController, animated: true, completion: nil)
注意
TakeASelfie使用swiftlint作为代码风格检查器,并使用常规样式。当构建框架目标时,运行一个脚本,它使用位于根文件夹中的配置文件调用swiftlint
。