简体   繁体   中英

Getting size (height and width) from PHAsset

Is there a way to get the height and width of the image from a PHAsset object.

I'm trying to make an image picker with a custom UICollectionViewLayout (Kind of like the main page of Pinterest app) I'v fetched all of the photos from the photo library into an array as PHAsset objects. But I need to get the size of the image from the PHAsset object for the delegate method collectionView:layout:sizeForItemAtIndexPath:

Is there a fast way to achieve this?

PHAsset具有pixelWidthpixelHeight属性。

You can get them using this.

let imgheight = yourAsset.pixelHeight
let imgwidth = yourAsset.pixelWidth

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM