美文网首页
2019-03-20

2019-03-20

作者: 瑷岚 | 来源:发表于2019-03-20 23:05 被阅读0次

day3:

PHAsset:图片库中图像、视频或实时照片的表示。

1、Fetching Assets 获取asset

2、Assets contain only metadata,可不存储在本地,可下载预览图,见PHImageManager

3、Asset objects are immutable,通过 PHAssetChangeRequest修改,见 PHPhotoLibrary

var mediaType: PHAssetMediaType//The type of the asset, such as video or audio.(enum PHAssetMediaType//Constants identifying the general type of an asset, such as image or video.)

var mediaSubtypes: PHAssetMediaSubtype//The subtypes of the asset, identifying special kinds of assets such as panoramic photo or high-framerate video.全景照片或高帧率视频。(struct PHAssetMediaSubtype//Constants identifying specific variations of asset media, such as panorama or screenshot photos and time lapse or high frame rate video.)

var sourceType: PHAssetSourceType//The means by which the asset entered the user’s Photos library. (struct PHAssetSourceType//Means by which an asset enters the Photos library, used by the PHAssetSourceTypeproperty.   UserLibrary、CloudShared、iTunesSynced )

var pixelWidth: Int //pixel 像素

var pixelHeight: Int

var creationDate: Date?//The date and time at which the asset was originally created.

var modificationDate: Date?//The date and time at which the asset was last modified. 修改

var location: CLLocation?//The location information saved with the asset.

var duration: TimeInterval//The duration, in seconds, of the video asset.

var isFavorite: Bool

var isHidden: Bool

var isSyncFailureHidden: Bool 同步失败隐藏

var playbackStyle: PHAsset.PlaybackStyle//An enumerated value that describes how to present an asset to the user. case unsupportedcase imagecase imageAnimatedcase livePhotocase videocase videoLooping

var burstIdentifier: String?//The unique identifier shared by photo assets from the same burst sequence. 连拍

var burstSelectionTypes: PHAssetBurstSelectionType//The selection type of the asset in a burst photo sequence.//.UserPick 表示用户手动标记的资源,.AutoPick 表示用户可能标记的潜在资源,.None 表示没有标记的资源。

var representsBurst: Bool//A Boolean value that indicates whether the asset is the representative photo from a burst photo sequence.

Fetching Assets:Retrieve asset metadata or request full asset content.

检索asset元数据或请求完整的asset内容。

class func fetchAssets(in: PHAssetCollection, options: PHFetchOptions?) -> PHFetchResult<PHAsset>

Retrieves assets from the specified asset collection.

class func fetchAssets(with: PHAssetMediaType, options: PHFetchOptions?) -> PHFetchResult<PHAsset>

Retrieves assets with the specified media type.

class func fetchAssets(withLocalIdentifiers: [String], options: PHFetchOptions?) -> PHFetchResult<PHAsset>

Retrieves assets with the specified local-device-specific unique identifiers.

class func fetchKeyAssets(in: PHAssetCollection, options: PHFetchOptions?) -> PHFetchResult<PHAsset>?

Retrieves assets marked as key assets in the specified asset collection.

class func fetchAssets(with: PHFetchOptions?) -> PHFetchResult<PHAsset>

Retrieves all assets matching the specified options.

class func fetchAssets(withBurstIdentifier: String, options: PHFetchOptions?) -> PHFetchResult

Retrieves assets with the specified burst photo sequence identifier.

Editing an Asset:Editing Asset Content//Make a request to modify and save a photo or video asset.

class PHContentEditingInput//A container that provides information about and access to the image, video, or Live Photo content of an asset to be edited.

class PHContentEditingOutput//A container to which you provide the results of editing the photo, video, or Live Photo content of a Photos asset.

class PHAdjustmentData//A description of the edits made to an asset's photo, video, or Live Photo content, which allows your app to reconstruct or revert the effects of prior editing sessions.

class PHContentEditingInputRequestOptions//A set of options affecting the delivery of image or video data when you request to edit the content of a Photos asset.

class PHLivePhotoEditingContext//An editing session for modifying the photo, video, and audio content of a Live Photo.

protocol PHLivePhotoFrame//A container that provides image content for a single frame of a Live Photo in an editing context.

func canPerform(PHAssetEditOperation) -> Bool//Returns whether the asset supports the specified editing operation.

enum PHAssetEditOperation//Values identifying possible actions an asset can support, used by the canPerform(_:) method.

func requestContentEditingInput(with: PHContentEditingInputRequestOptions?, completionHandler: (PHContentEditingInput?, [AnyHashable : Any]) -> Void) -> PHContentEditingInputRequestID//Requests asset information for beginning a content editing session.

func cancelContentEditingInputRequest(PHContentEditingInputRequestID)

Cancels a request for editing the asset’s content.

typealias PHContentEditingInputRequestID//An identifier for an asset content editing session.

Editing Request Info Keys

Keys indicating the status of an asset content editing request, used in the completion handler of the requestContentEditingInput(with:completionHandler:)method.

Asset Retrieval

Fetching Objects and Requesting Changes

Get assets, asset collections, and collection lists matching a specified query.

class PHAssetCollection

A representation of a Photos asset grouping, such as a moment, user-created album, or smart album.

class PHCollection

The abstract superclass for Photos asset collections and collection lists.

class PHCollectionList

A group containing Photos asset collections, such as Moments, Years, or folders of user-created albums.

class PHObject

The abstract superclass for Photos model objects (assets and collections).

class PHFetchResult

An ordered list of assets or collections returned from a Photos fetch method.

class PHFetchOptions

A set of options that affect the filtering, sorting, and management of results that Photos returns when you fetch asset or collection objects.

相关文章

网友评论

      本文标题:2019-03-20

      本文链接:https://www.haomeiwen.com/subject/mvvxvqtx.html