一个自定义图片选择器
使用方法:
1 引入头文件
#import "XDPicLibrary.h"
2 在点击事件中进行跳转
XDPicLibrary *root = [[XDPicLibrary alloc]initBackInfo:^(NSMutableArray *assets) {
/*
assets 为图片资源组, 不是直接的 Image,如果用 Image 的话需要 转换,转换方法:
imageAsset = assets[index];
//获取大图资源
ALAssetRepresentation *presentation = [imageAsset defaultRepresentation];
//大图
CGImageRef original = [presentation fullResolutionImage];
//image
UIImage *originalImage = [UIImage imageWithCGImage:original];
//获取缩略图
CGImageRef thumbnail = [itemAsset thumbnail];
//转为 image
UIImage *image = [UIImage imageWithCGImage:thumbnail];
*/
}];
//设置一次性选择的最大张数
root.maxNumber = 1;
//设置图片
// [root setImage:nil selectedImage:[UIImage imageNamed:nil]];
//设置选中按钮的选中前 & 选中后的颜色
// [root setColor:[UIColor clearColor] selectedColor:[UIColor blueColor]];
//设置选中按钮的边框颜色
// [root setMarkBorderColor:[UIColor whiteColor]];
/*
由于笔者比较懒,懒得再去弄 navBar 的东西,当前只能 push 过去,如果想 present 过去的话,需要自行实现
XDPicLibrary 的 navBar,并且把左右按钮的点击事件对应起来就 OK 了
*/
[self.navigationController pushViewController:root animated:YES];
}