ALAsset类代表相册中的每个资源文件,可以通过它获取资源文件的相关信息还能修改和新建资源文件,ALAssetRepresentation类代表相册中每个资源文件的详细信息,可以通过它获取资源的大小,名字,路径等详细信息。
ALAsset *asset = 对象;
//获取时间
NSDate* pictureDate = [asset valueForProperty:ALAssetPropertyDate];
NSDateFormatter * formatter = [[NSDateFormatter alloc]init];
formatter.dateFormat = @"yyyy:MM:dd HH:mm:ss";
formatter.timeZone = [NSTimeZone localTimeZone];//要换成本地的时区,才能获得正确的时间
NSString * pictureTime = [formatter stringFromDate:pictureDate];
//获取url:
NSURL *imageUrl = [[asset defaultRepresentation]url];
//获取缩略图:
CGImageRef thumbnailRef = [asset thumbnail];
UIImage *thumbnailImg = [[UIImage alloc]initWithCGImage:thumbnailRef];
//获取全屏相片:
CGImageRef fullScreenRef = [[asset defaultRepresentation]fullScreenImage];
UIImage *fullScreenImg = [[UIImage alloc]initWithCGImage:fullScreenRef];
//获取高清相片:
CGImageRef origionRef = [[asset defaultRepresentation]fullResolutionImage];
UIImage *origionImg = [[UIImage alloc]initWithCGImage:origionRef];