2017-02-10 51 views

回答

0

时间戳可用于与图像一起存储的EXIF数据。你可以得到它使用的UIImagePickerController这样的:

https://stackoverflow.com/a/33672661/4042468

在另一方面,如果你有图像文件的网址,你可以使用import ImageIO和下面的代码来获取图像的所有属性,其日期时间是一个。

if let imagePath = Bundle.main.path(forResource: "test", ofType: "jpg") { 
     let imageURL = NSURL(fileURLWithPath: imagePath) 

     if let imageSource = CGImageSourceCreateWithURL(imageURL, nil) { 
      if let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as? [String: AnyObject] { 

      } 
     } 
    } 

请注意,有一个Exif键可以找到时间戳。

+0

我没有使用图像选择控制器我直接从图库共享图像,所以我想图像的时间 –

+0

@DeepakSaki现在来看看。 – kerry

+0

是否有可能借助资产网址,因为我直接从图库共享图片。资产网址未在文件路径中传递。 –