解决方法
这是怎么做到的,但是我必须警告你这是缓慢的(ish)和框架所需要的这是内存密集型,因为它遍历ALAssetsLibrary寻找海报图像.
这在后台线程上,所以UI更改被发送到主线程进行渲染.
这在后台线程上,所以UI更改被发送到主线程进行渲染.
self.assetsLibrary = [[ALAssetsLibrary alloc] init]; NSUInteger groupTypes = ALAssetsGroupAlbum | ALAssetsGroupSavedPhotos | ALAssetsGroupPhotoStream; [self.assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:^(ALAssetsGroup *group,BOOL *stop) { if (group.posterImage != nil) { dispatch_async(dispatch_get_main_queue(),^{ self.pictureLayer.contents = (__bridge_transfer id) CGImageCreateCopy(group.posterImage); [self.layer setNeedsDisplay]; self.assetsLibrary = nil; *stop = YES; }); } } failureBlock:^(NSError *error) { self.assetsLibrary = nil; NSLog(@"AssetLib error:%@",error); }];