https://github.com/kk-vv/himagepickerutils-swift
Swift4.0 - iOS 照片选取和拍照, 支持closure 回调
https://github.com/kk-vv/himagepickerutils-swift
closure imagepick swift
Last synced: 8 months ago
JSON representation
Swift4.0 - iOS 照片选取和拍照, 支持closure 回调
- Host: GitHub
- URL: https://github.com/kk-vv/himagepickerutils-swift
- Owner: kk-vv
- License: mit
- Created: 2015-10-30T03:32:54.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-12-08T02:55:21.000Z (over 8 years ago)
- Last Synced: 2025-04-01T14:14:52.080Z (about 1 year ago)
- Topics: closure, imagepick, swift
- Language: Swift
- Homepage:
- Size: 746 KB
- Stars: 14
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swift-照片选取和拍照
### Tips
---
- 支持照片选取和拍照
- 支持Closure回调
`注意Info.plist设置`
```
Privacy - Camera Usage Description
Privacy - Photo Library Usage Description
```
### 使用方法
---
- 定义为类的成员变量
```
lazy var imagePicker = HImagePickerUtils()
//不能为临时变量,临时变量销毁时,UIImagePickerController代理方法不会回调
```
- 拍一张
```
imagePicker.takePhoto(presentFrom: self, completion: { [unowned self] (image, status) in
if status == .success {
self.image.image = image
}else{
if status == .denied{
HImagePickerUtils.showTips(at: self,type: .takePhoto)
}else{
print(status.description())
}
}
})
```
- 从相册取
```
imagePicker.choosePhoto(presentFrom: self, completion: { [unowned self] (image, status) in
if status == .success {
self.image.image = image
}else{
if status == .denied{
HImagePickerUtils.showTips(at: self,type: .choosePhoto)
}else{
print(status.description())
}
}
})
```
### 效果图
---
>
