-2
    func mapView(_ mapView: MapViewPlus, imageFor annotation: AnnotationPlus) -> UIImage {

    let image: UIImage! = UIImage(named: "basic_annotation_image.png")
    let imageView: UIImageView = UIImageView(image: image)
    imageView.layer.cornerRadius = imageView.frame.width / 2
    imageView.clipsToBounds = true
    imageView.layer.borderColor =  UIColor.white.cgColor
    imageView.layer.borderWidth = 4

    // Now i want to convert this imageView to UIImage

    return UIImage(named: "basic_annotation_image.png")!
}

I want to convert UIImageView to UIImage. Anyone know that how to do that?[enter image description here]

VentralRumble
  • 35
  • 1
  • 6
  • 1
    Never post code as image. See: [How to write a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – sɐunıɔןɐqɐp Jul 04 '18 at 07:07
  • 5
    Possible duplicate of [Create UIImage from a UIImageView](https://stackoverflow.com/questions/20719518/create-uiimage-from-a-uiimageview) – sɐunıɔןɐqɐp Jul 04 '18 at 07:08
  • Also see: [How to convert a UIView to an image](https://stackoverflow.com/questions/30696307/how-to-convert-a-uiview-to-an-image) – Roman Aliyev Jun 09 '22 at 16:32

1 Answers1

2

You cannot convert UIImageView to UIImage, but you can use the image from the UIImageView:

let image: UIImage = yourImageView.image
S.S.D
  • 1,579
  • 2
  • 12
  • 23