@@ -29,7 +29,7 @@ import Photos
29
29
30
30
public class ZLPhotoManager : NSObject {
31
31
32
- /// save image to album
32
+ /// Save image to album.
33
33
@objc public class func saveImageToAlbum( image: UIImage , completion: ( ( Bool , PHAsset ? ) -> Void ) ? ) {
34
34
let status = PHPhotoLibrary . authorizationStatus ( )
35
35
@@ -54,7 +54,7 @@ public class ZLPhotoManager: NSObject {
54
54
}
55
55
}
56
56
57
- /// save video to album
57
+ /// Save video to album.
58
58
@objc public class func saveVideoToAlbum( url: URL , completion: ( ( Bool , PHAsset ? ) -> Void ) ? ) {
59
59
let status = PHPhotoLibrary . authorizationStatus ( )
60
60
@@ -90,7 +90,7 @@ public class ZLPhotoManager: NSObject {
90
90
return nil
91
91
}
92
92
93
- /// fetch photos from result
93
+ /// Fetch photos from result.
94
94
class func fetchPhoto( in result: PHFetchResult < PHAsset > , ascending: Bool , allowSelectImage: Bool , allowSelectVideo: Bool , limitCount: Int = . max) -> [ ZLPhotoModel ] {
95
95
var models : [ ZLPhotoModel ] = [ ]
96
96
let option : NSEnumerationOptions = ascending ? . init( rawValue: 0 ) : . reverse
@@ -116,7 +116,7 @@ public class ZLPhotoManager: NSObject {
116
116
return models
117
117
}
118
118
119
- /// fetch all album list
119
+ /// Fetch all album list.
120
120
class func getPhotoAlbumList( ascending: Bool , allowSelectImage: Bool , allowSelectVideo: Bool , completion: ( ( [ ZLAlbumListModel ] ) -> Void ) ) {
121
121
let option = PHFetchOptions ( )
122
122
if !allowSelectImage {
@@ -150,7 +150,7 @@ public class ZLPhotoManager: NSObject {
150
150
let title = self . getCollectionTitle ( collection)
151
151
152
152
if collection. assetCollectionSubtype == . smartAlbumUserLibrary {
153
- // 所有照片
153
+ // Album of all photos.
154
154
let m = ZLAlbumListModel ( title: title, result: result, collection: collection, option: option, isCameraRoll: true )
155
155
albumList. insert ( m, at: 0 )
156
156
} else {
@@ -163,7 +163,7 @@ public class ZLPhotoManager: NSObject {
163
163
completion ( albumList)
164
164
}
165
165
166
- /// fetch camera roll album
166
+ /// Fetch camera roll album.
167
167
class func getCameraRollAlbum( allowSelectImage: Bool , allowSelectVideo: Bool , completion: @escaping ( ( ZLAlbumListModel ) -> Void ) ) {
168
168
let option = PHFetchOptions ( )
169
169
if !allowSelectImage {
@@ -184,10 +184,10 @@ public class ZLPhotoManager: NSObject {
184
184
}
185
185
}
186
186
187
- /// conversion collection title
187
+ /// Conversion collection title.
188
188
private class func getCollectionTitle( _ collection: PHAssetCollection ) -> String {
189
189
if collection. assetCollectionType == . album {
190
- // 用户创建的相册
190
+ // Albums created by user.
191
191
var title : String ? = nil
192
192
if ZLCustomLanguageDeploy . language == . system {
193
193
title = collection. localizedTitle
@@ -255,7 +255,7 @@ public class ZLPhotoManager: NSObject {
255
255
return self . fetchImage ( for: asset, size: PHImageManagerMaximumSize, resizeMode: . fast, progress: progress, completion: completion)
256
256
}
257
257
258
- /// fetch asset data
258
+ /// Fetch asset data.
259
259
@discardableResult
260
260
class func fetchOriginalImageData( for asset: PHAsset , progress: ( ( CGFloat , Error ? , UnsafeMutablePointer < ObjCBool > , [ AnyHashable : Any ] ? ) -> Void ) ? = nil , completion: @escaping ( ( Data , [ AnyHashable : Any ] ? , Bool ) -> Void ) ) -> PHImageRequestID {
261
261
let option = PHImageRequestOptions ( )
@@ -280,14 +280,9 @@ public class ZLPhotoManager: NSObject {
280
280
}
281
281
}
282
282
283
- /// fetch image for asset
283
+ /// Fetch image for asset.
284
284
private class func fetchImage( for asset: PHAsset , size: CGSize , resizeMode: PHImageRequestOptionsResizeMode , progress: ( ( CGFloat , Error ? , UnsafeMutablePointer < ObjCBool > , [ AnyHashable : Any ] ? ) -> Void ) ? = nil , completion: @escaping ( ( UIImage ? , Bool ) -> Void ) ) -> PHImageRequestID {
285
285
let option = PHImageRequestOptions ( )
286
- /**
287
- resizeMode:对请求的图像怎样缩放。有三种选择:None,默认加载方式;Fast,尽快地提供接近或稍微大于要求的尺寸;Exact,精准提供要求的尺寸。
288
- deliveryMode:图像质量。有三种值:Opportunistic,在速度与质量中均衡;HighQualityFormat,不管花费多长时间,提供高质量图像;FastFormat,以最快速度提供好的质量。
289
- 这个属性只有在 synchronous 为 true 时有效。
290
- */
291
286
option. resizeMode = resizeMode
292
287
option. isNetworkAccessAllowed = true
293
288
option. progressHandler = { ( pro, error, stop, info) in
@@ -306,7 +301,6 @@ public class ZLPhotoManager: NSObject {
306
301
completion ( image, isDegraded)
307
302
}
308
303
}
309
-
310
304
}
311
305
312
306
class func fetchLivePhoto( for asset: PHAsset , completion: @escaping ( ( PHLivePhoto ? , [ AnyHashable : Any ] ? , Bool ) -> Void ) ) -> PHImageRequestID {
@@ -330,7 +324,7 @@ public class ZLPhotoManager: NSObject {
330
324
}
331
325
}
332
326
return PHImageManager . default ( ) . requestPlayerItem ( forVideo: asset, options: option) { ( item, info) in
333
- // iOS11 系统这个回调没有在主线程
327
+ // iOS11 and earlier, callback is not on the main thread.
334
328
DispatchQueue . main. async {
335
329
let isDegraded = ( info ? [ PHImageResultIsDegradedKey] as? Bool ?? false )
336
330
completion ( item, info, isDegraded)
@@ -360,7 +354,7 @@ public class ZLPhotoManager: NSObject {
360
354
}
361
355
}
362
356
363
- /// fetch asset local file path
357
+ /// Fetch asset local file path.
364
358
@objc public class func fetchAssetFilePath( asset: PHAsset , completion: @escaping ( String ? ) -> Void ) {
365
359
asset. requestContentEditingInput ( with: nil ) { ( input, info) in
366
360
var path = input? . fullSizeImageURL? . absoluteString
@@ -374,7 +368,7 @@ public class ZLPhotoManager: NSObject {
374
368
}
375
369
376
370
377
- /// authority related
371
+ /// Authority related.
378
372
extension ZLPhotoManager {
379
373
380
374
public class func havePhotoLibratyAuthority( ) -> Bool {
0 commit comments