ALAsset 的用法(时间、url 、图片的获取)

    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];

你可能感兴趣的:(iOS,视频,语音,图片)