Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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/7/image/5.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
Swift 未在UIImageView中渲染图像_Swift_Image_Uiimageview - Fatal编程技术网

Swift 未在UIImageView中渲染图像

Swift 未在UIImageView中渲染图像,swift,image,uiimageview,Swift,Image,Uiimageview,由下面的函数生成的此图像拒绝显示在UIImageView中 这是iOS问题还是生成映像时出错 多谢各位 private func plotLogGraph(_ samples: [CGFloat], maximumValue max: CGFloat, zeroValue min: CGFloat, imageHeight: CGFloat,color:UIColor) -> UIImage? { let imageSize = CGSize(width: CGFloat(sam

由下面的函数生成的此图像拒绝显示在UIImageView中

这是iOS问题还是生成映像时出错

多谢各位

private func plotLogGraph(_ samples: [CGFloat], maximumValue max: CGFloat, zeroValue min: CGFloat, imageHeight: CGFloat,color:UIColor) -> UIImage? {
    let imageSize = CGSize(width: CGFloat(samples.count), height: imageHeight)
    UIGraphicsBeginImageContext(imageSize)
    guard let context = UIGraphicsGetCurrentContext() else {
        return nil
    }

    context.setAlpha(1.0)
    context.setLineWidth(1.0)
    context.setStrokeColor(color.cgColor)

    let sampleDrawingScale: CGFloat
    if max == min {
        sampleDrawingScale = 0
    } else {
        sampleDrawingScale = imageHeight / 2 / (max - min)
    }
    let verticalMiddle = imageHeight / 2
    for (x, sample) in samples.enumerated() {
        let height = (sample - min) * sampleDrawingScale
        context.move(to: CGPoint(x: CGFloat(x), y: verticalMiddle - height))
        context.addLine(to: CGPoint(x: CGFloat(x), y: verticalMiddle + height))
        context.strokePath();
    }
    guard let image = UIGraphicsGetImageFromCurrentImageContext() else {
        return nil;
    }

    UIGraphicsEndImageContext()
    return image;
}

渲染示例只是显示图像的全屏图像视图,请参见

它拒绝显示在imageview中是什么意思?dropbox中的图像在ImageView中工作正常显示代码。显示如何将图像指定给imageView等。渲染示例仅为显示图像的全屏imageView,请参阅