ADPhotoKit is a pure-Swift library to select assets (e.g. photo,video,gif,livephoto) from system album. Default appearance is Wechat-like.
- Well documentation.
- Supports both single and multiple selection.
- Supports filtering albums and sorting by type.
- iCloud Support.
- Multi-language.
- Highly customizable base on protocol(UI/Image/Color/Font).
- UIAppearance support.
- Supports batch export PHAsset to image.
- Image editor.
- Video editor.
- DocC support.
- SwiftUI support.
- Custom capture support.
The simplest use-case is present the image picker on your controller:
ADPhotoKitUI.imagePicker(present: self) { (assets, origin) in
// do something
}
Also you can present the image pricker on swiftUI:
import SwiftUI
struct SwiftUIView: View {
@State private var showImagePicker = false
var body: some View {
Button("PickerImage") {
showImagePicker.toggle()
}
.imagePicker(isPresented: $showImagePicker,
selected: { (assets, origin) in
// do something
})
}
}
Select up to 9 images or videos:
ADPhotoKitUI.imagePicker(present: self,
params: [.maxCount(max: 9)],
selected: { (assets, origin) in
// do something
})
Select 1 video or 9 images:
ADPhotoKitUI.imagePicker(present: self,
assetOpts: .exclusive,
params: [.maxCount(max: 9),.imageCount(min: nil, max: 9),.videoCount(min: nil, max: 1)],
selected: { (assets, origin) in
// do something
})
Select max 8 images:
ADPhotoKitUI.imagePicker(present: self,
albumOpts: [.allowImage],
assetOpts: .exclusive,
params: [.maxCount(max: 8)],
selected: { (assets, origin) in
// do something
})
Browser network image and video:
ADPhotoKitUI.assetBrowser(present: self,
assets: [NetImage(url: "https://example.com/xx.png"), NetVideo(url: "https://example.com/xx.mp4")]) { assets in
// do something
}
For more usage configuration, you can see ADPhotoKitConfiguration and SelectionRestrict.
To lean more use of ADPhotoKit, refer to the example and API Reference.
- iOS 10.0
- Swift 5.0+
- Xcode 15+
Objective-C is not supported. Swift is the future and dropping Obj-C is the price to pay to keep our velocity on this library :)
ADPhotoKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
source 'https://cdn.cocoapods.org/'
platform :ios, '10.0'
use_frameworks!
target 'MyApp' do
pod 'ADPhotoKit'
end
DocC support need cocoaPods 1.12.0+
There are 4 subspecs available now:
Subspec | Description |
---|---|
Base | Required. This subspec provides base configuration and extensions. |
Core | Optional. This subspec provides raw data. Depend on Base subspec. |
CoreUI | Optional. The subspec provides ui for photo select. Depend on Core subspec. |
ImageEdit | Optional. The subspec provides image edit ability. Depend on Base subspec. |
VideoEdit | Optional. The subspec provides video edit ability. Depend on Base subspec. |
You can install only some of the ADPhotoKit modules. By default, you get CoreUI
subspecs.
- File > Swift Packages > Add Package Dependency
- Add https://github.com/duzexu/ADPhotoKit.git
- Select "Branch" with "master"
You need to add the following key-value pairs in your app's Info.plist
// If you don’t add this key-value pair, multiple languages are not supported, and the system PhotoKitUI language defaults to English
Localized resources can be mixed YES
// You must add follow in your app's Info.plist
Privacy - Photo Library Usage Description
// If you `assetOpts` contain `allowTakePhotoAsset`, you must add follow
Privacy - Camera Usage Description
// If you `assetOpts` contain `allowTakeVideoAsset`, you must add follow
Privacy - Microphone Usage Description
If you have feature requests or bug reports, feel free to help out by sending pull requests or by creating new issues.
ADPhotoKit is available under the MIT license. See the LICENSE file for more info.
Some code and resource are copy from ZLPhotoBrowser