Ios 在Swift中与UIActivityViewController共享时向UIImage添加GPS元数据

Ios 在Swift中与UIActivityViewController共享时向UIImage添加GPS元数据,ios,swift,gps,uiimage,metadata,Ios,Swift,Gps,Uiimage,Metadata,我正在使用用户选择的UIColor在Swift中创建UIImage,我希望在使用UIActivityViewController保存或共享图像时,将一些元数据附加到该图像。我特别希望将GPS坐标附加到图像上。我看到很多问题看起来很接近,并且参考了ImageIO框架,但大多数问题似乎都与从UIImagePicker中选择的图像有关。以下是我最初创建图像的功能: class func fromColor(color: UIColor) -> UIImage { let rect = C

我正在使用用户选择的UIColor在Swift中创建UIImage,我希望在使用UIActivityViewController保存或共享图像时,将一些元数据附加到该图像。我特别希望将GPS坐标附加到图像上。我看到很多问题看起来很接近,并且参考了ImageIO框架,但大多数问题似乎都与从UIImagePicker中选择的图像有关。以下是我最初创建图像的功能:

class func fromColor(color: UIColor) -> UIImage {
    let rect = CGRect(x: 0, y: 0, width: 1080, height: 1080)
    UIGraphicsBeginImageContext(rect.size)
    let context = UIGraphicsGetCurrentContext()
    CGContextSetFillColorWithColor(context, color.CGColor)
    CGContextFillRect(context, rect)
    let newImage = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    return newImage
}
我知道UIImage本身没有附加元数据,但在将图像保存到卷或以其他方式共享时,是否有方法设置GPS元数据?我是一个相对较新的开发人员,所以尝试将C代码翻译成Swift有点让我不知所措