https://github.com/loopeer/lpalbum
an albums that can preview, multiple-choice
https://github.com/loopeer/lpalbum
album imagepick imagepicker ios photo photobrowser photos swift
Last synced: 2 months ago
JSON representation
an albums that can preview, multiple-choice
- Host: GitHub
- URL: https://github.com/loopeer/lpalbum
- Owner: loopeer
- License: mit
- Created: 2017-09-13T11:06:13.000Z (over 8 years ago)
- Default Branch: dev
- Last Pushed: 2018-01-19T03:54:34.000Z (over 8 years ago)
- Last Synced: 2025-04-08T06:35:29.399Z (about 1 year ago)
- Topics: album, imagepick, imagepicker, ios, photo, photobrowser, photos, swift
- Language: Swift
- Homepage:
- Size: 1.42 MB
- Stars: 17
- Watchers: 10
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LPAlbum




**LPAlbum** is a simple photo album
## Overview
**LPAlbum** is a album including the function of multiple images, photo browsing, camera taking pictures. It is very easy to use
## How to use
1. Config
```Swift
public extension LPAlbum {
public struct Config {
/// 最大选择数量
public var maxSelectCount: Int = 6
/// 每列照片数量
public var columnCount: Int = 4
/// 照片间距
public var photoPadding: CGFloat = 2.0
/// 是否有相机
public var hasCamera: Bool = true
}
public struct Style {
/// `NavigationBar`标题颜色
public static var barTitleColor: UIColor = UIColor.white
/// `NavigationBar`背景颜色
public static var barTintColor: UIColor = UIColor.darkGray
/// `NavigationBar`item文本颜色
public static var tintColor: UIColor = UIColor.white
/// 状态栏样式
public static var statusBarStyle: UIStatusBarStyle = .lightContent
/// 下拉箭头图片
public static var arrowImage: UIImage = Bundle.imageFromBundle("meun_down")!
/// 正常的选择框图片
public static var normalBox: UIImage = Bundle.imageFromBundle("circle_normal")!
/// 选中的选择框图片
public static var selectedBox: UIImage = Bundle.imageFromBundle("circle_selected")!
/// 选择框box的可点击区域向外的扩展size
public static var boxEdgeInsets = UIEdgeInsets(top: -5, left: -5, bottom: -5, right: -5)
}
}
```
2. Error:
```Swift
public enum AlbumError: Error {
case noAlbumPermission
case noCameraPermission
case moreThanLargestChoiceCount
case savePhotoError
public var localizedDescription: String {
switch self {
case .noAlbumPermission: return String.local("没有相册访问权限")
case .noCameraPermission: return String.local("没有摄像头访问权限")
case .moreThanLargestChoiceCount: return String.local("达到了图片选择最大数量")
case .savePhotoError: return String.local("保存图片失败")
}
}
}
```
3. Use:
> Tips: add row in your project info.plist
> 1. `Privacy - Photo Library Usage Description` : `Can I get photo album permissions?`
> 2. `Privacy - Camera Usage Description` : `Can I get camera permissions?`
> 3. `Localization native development region` : `en` or `china`
```Swift
// you can setup style yourself
LPAlbum.Style.barTintColor = .gray
LPAlbum.Style.tintColor = .white
// show
LPAlbum.show(at: self) {
$0.columnCount = 4
$0.hasCamera = true
$0.maxSelectCount = 9 - self.photos.count
}.targeSize({ (size) -> CGSize in
return CGSize(width: 240, height: 240)
}).error {(vc, error) in
vc.show(message: error.localizedDescription)
}.complete { [weak self](images) in
self?.photos.append(contentsOf: images)
self?.collectionView.reloadData()
_ = images.map{ print($0.size) }
}
```
## Features
- [ ] Support for iCloud
- [ ] Support for cutting
- [ ] Support for selecting a single image
- [ ] Support for choosing the original image
- [ ] Add preview of the selected photos
## Installation
### 1. CocoaPods
[CocoaPods](https://cocoapods.org/) is a dependency manager for Cocoa projects.
Specify LPAlbum into your project's Podfile:
```ruby
# source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '' do
pod 'LPAlbum', '~> 0.0.9'
end
```
Then run the following command:
```sh
$ pod install
```