Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将uiimage视图转换为uiimage_Ios_Uiimageview_Uiimage - Fatal编程技术网

Ios 将uiimage视图转换为uiimage

Ios 将uiimage视图转换为uiimage,ios,uiimageview,uiimage,Ios,Uiimageview,Uiimage,我想将UIImageView转换为UIImage。有人知道怎么做吗?[在此处输入图像描述]您不能将UIImageView转换为UIImage,但可以使用UIImageView中的图像: func mapView(_ mapView: MapViewPlus, imageFor annotation: AnnotationPlus) -> UIImage { let image: UIImage! = UIImage(named: "basic_annotation_ima

我想将UIImageView转换为UIImage。有人知道怎么做吗?[在此处输入图像描述]

您不能将UIImageView转换为UIImage,但可以使用UIImageView中的图像:

    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")!
}

永远不要将代码作为图像发布。请参阅:。可能的副本
let image: UIImage = yourImageView.image