yfp

YFPhotoAlbum

自定义相册,支持单选、多选,同时支持PHotoKit和ALAssetLibrary

Showing:

Popularity

Downloads/wk

0

GitHub Stars

36

Maintenance

Last Commit

3yrs ago

Contributors

2

Package

Dependencies

0

License

MIT

Categories

Readme

YFPhotoAlbum

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

iOS7+

ScreenShot

下拉式相册分组       相册展示

照片大图预览

Installation

  • 通过CocoaPods安装  

YFPhotoAlbum 支持通过 CocoaPods进行安装。 在Podfile文件中加上

pod "YFPhotoAlbum"
  • 直接加项目中使用
git clone https://github.com/lovisty/YFPhotoAlbum   

1、在 Build Phases 里分别添加 Photos.framework 和 AssetsLibrary.framework 框架。

2、在 plist 文件里添加权限声明 Privacy - Photo Library Usage Description 和 Privacy - Camera Usage Description

3、找到包含的文件Classes和Assets的YFPhotoAlbum文件,直接把YFPhotoAlbum拖到项目中。

导入头文件:

#import "YFCustomPhotoAlbumViewController.h"  

Usage

初始化以及相关回调

self.photoAlbumViewController = [[YFCustomPhotoAlbumViewController alloc] init];
self.photoAlbumViewController.maxCount = 9;// maxCount > 0, 默认是 1.
self.photoAlbumViewController.selectedAssets = self.selectedAssets;//再次进入相册选择的时候,保留已选择的为选中状态。

//超过最大值的回调
self.photoAlbumViewController.amountBeyondBlock = ^(){ 
    //可以用来提醒用户超过最大值
};
 
//选择结果  
self.photoAlbumViewController.assetsResultBlock = ^(NSMutableArray *assets){
    //优化内存,此处的assets为对象,而非图片本身。
};

获取图片

    for (id objc in assets) {
        if ([objc isKindOfClass:[UIImage class]]) { //拍照的结果
            //objc 即为图片;
        }else if ([objc isKindOfClass:[PHAsset class]]){ //PhotoKit
            PHAsset *asset = objc;
            PHImageManager *imageManger = [PHImageManager defaultManager];
            [imageManger requestImageForAsset:asset targetSize:CGSizeMake(80*2, 80*2) contentMode:PHImageContentModeDefault options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
                //result 即为图片;
            }];
        }else if ([objc isKindOfClass:[ALAsset class]]){ //ALAssetLibrary
            ALAsset *asset = objc;
            UIImage *image = [UIImage imageWithCGImage:asset.thumbnail];
            //image 即为图片;
            
        }
    }

Author

YaFei, nihao1992@163.com

个人博客:http://blog.csdn.net/u013749108

License

YFPhotoAlbum is available under the MIT license. See the LICENSE file for more info.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100