1
私は以下のコードに従っていますし、image.whatが間違っているのを表示していませんか?私はnewimage show nilをデバッグしようとしていました。スウィフト3.0で画像に緯度と経度を書き込む方法は?
私は任意のヘルプが
func textOnImage(text: NSString, atPoint: CGPoint,capturedImage:UIImage?) -> UIImage?{
if let capturedImage = capturedImage{
// Setup the font specific variables
let textColor = UIColor.white
let textFont = UIFont(name: "Helvetica", size: 14)!
// Setup the image context using the passed image
let scale = UIScreen.main.scale
UIGraphicsBeginImageContextWithOptions(capturedImage.size, false, scale)
// Setup the font attributes that will be later used to dictate how the text should be drawn
let textFontAttributes = [
NSFontAttributeName: textFont,
NSForegroundColorAttributeName: textColor,
] as [String : Any]
// Create a point within the space that is as bit as the image
let rect = CGRect(x: atPoint.x, y: atPoint.y, width: capturedImage.size.width, height: capturedImage.size.height)
// Draw the text into an image
text.draw(in: rect, withAttributes: textFontAttributes)
// Create a new image out of the images we have created
let newImage = UIGraphicsGetImageFromCurrentImageContext()
// End the context now that we have the image we need
UIGraphicsEndImageContext()
//Pass the image back up to the caller
return newImage!
}
return nil
}
が欠落している画像フレームのように見えるようなので、あなたの方法に見える
線の下に含めます。 – adarshaU
を確認してください可能性がある場所を教えてください。 – Mickel