swift에서 옵션을 주고 사진을 가져오는 방법이있나요?
조회수 2318회
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
PHAsset를 가지고 오신 다음
- 날짜 같은 경우 asset.creationDate
- 장소 같은 경우 asset.location
- 사진 크기는 asset.pixelWidth, asset.pixelHeight
정보를 가지고 와서 비교 하신다음 사진들 가지고 오시면 될꺼 같아요 :)
import Photos override func viewDidLoad() { let options = PHFetchOptions() options.predicate = NSPredicate(format: "mediaType = %d",PHAssetMediaType.Image.rawValue) options.sortDescriptors = [ NSSortDescriptor(key: "creationDate", ascending: true) ] let result : PHFetchResult = PHAsset.fetchAssetsWithOptions(options) for i in 0 ..< assetsFetchResults.count { let asset = assetsFetchResults[i] as! PHAsset print("date = \(asset.creationDate!)") print("location = \(asset.location)") print("width = \(asset.pixelWidth), height=\(asset.pixelHeight)) } }
댓글 입력