iOS PhotoKit:获取除全景照片以外的所有智能相册

我使用以下代码来获取所有智能相册:

PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.smartAlbum, subtype: PHAssetCollectionSubtype.albumRegular, options: nil)

如何从此抓取中排除Panoramas智能相册? 我假设我必须使用options param添加谓词,但我不知道如何格式化谓词。

如果要排除全景图,请考虑使用数组并仅获取所需的集合。 换句话说,白名单集合。 或者您可以枚举整个集合并排除全景图。 白名单还可以控制集合的顺序。

 var smartAlbums: [PHAssetCollection] = [] let subtypes:[PHAssetCollectionSubtype] = [ // all photos collection // .smartAlbumUserLibrary, .smartAlbumFavorites, .smartAlbumPanoramas, .smartAlbumLivePhotos, .smartAlbumBursts, .smartAlbumDepthEffect, .smartAlbumLongExposures, .smartAlbumScreenshots, .smartAlbumSelfPortraits ] smartAlbums = fetchSmartCollections(with: .smartAlbum, subtypes: subtypes) private func fetchSmartCollections(with: PHAssetCollectionType, subtypes: [PHAssetCollectionSubtype]) -> [PHAssetCollection] { var collections:[PHAssetCollection] = [] let options = PHFetchOptions() options.includeHiddenAssets = false for subtype in subtypes { if let collection = PHAssetCollection.fetchAssetCollections(with: with, subtype: subtype, options: options).firstObject { collections.append(collection) } } return collections }