LPAlbum is a simple photo album
LPAlbum is a album including the function of multiple images, photo browsing, camera taking pictures. It is very easy to use
- Config
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)
}
}
- Error:
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("保存图片失败")
}
}
}
- Use:
Tips: add row in your project info.plist
Privacy - Photo Library Usage Description
:Can I get photo album permissions?
Privacy - Camera Usage Description
:Can I get camera permissions?
Localization native development region
:en
orchina
// 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) }
}
- Support for iCloud
- Support for cutting
- Support for selecting a single image
- Support for choosing the original image
- Add preview of the selected photos
CocoaPods is a dependency manager for Cocoa projects.
Specify LPAlbum into your project's Podfile:
# source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your App Target>' do
pod 'LPAlbum', '~> 0.0.9'
end
Then run the following command:
$ pod install