標籤:set bsp script color integer fail bool 生產 error
直接上代碼:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) { // Filter down to only photos [group setAssetsFilter:[ALAssetsFilter allPhotos]]; // Grab the first photo return [group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:0] options:0 usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { if (result) { id repressentation = [result defaultRepresentation]; // 可以生產一個AVAsset NSURL *url = [repressentation url]; AVAsset *asset = [AVAsset assetWithURL:url]; // 也可以直接擷取image self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithCGImage:[repressentation fullResolutionImage]]]; } }]; } failureBlock:^(NSError *error) { NSLog(@"Error: %@", [error localizedDescription]); }];
iOS-使用ALAssetsLibrary擷取相簿圖片視頻