ios – 找不到金属’质地’

随着每个基于Metal的 ImageView的实现,我都面临同样的问题
let targetTexture = currentDrawable?.texture else{ return }

Value of type ‘MTLDrawable’ has no member ‘texture’

好像苹果改变了一些金属api

这是我试用的全部功能

func renderImage()
{
    guard let
        image = image,let targetTexture = currentDrawable?.texture else{return}

    let commandBuffer = commandQueue.makeCommandBuffer()

    let bounds = CGRect(origin: CGPoint.zero,size: drawableSize)

    let originX = image.extent.origin.x
    let originY = image.extent.origin.y

    let scaleX = drawableSize.width / image.extent.width
    let scaleY = drawableSize.height / image.extent.height
    let scale = min(scaleX,scaleY)

    let scaledImage = image
        .applying(CGAffineTransform(translationX: -originX,y: -originY))
        .applying(CGAffineTransform(scaleX: scale,y: scale))

    ciContext.render(scaledImage,to: targetTexture,commandBuffer: commandBuffer,bounds: bounds,colorSpace: colorSpace)

    commandBuffer.present(currentDrawable!)

    commandBuffer.commit()
}

解决方法

执行系统和xcode更新后,我遇到了同样的问题.在更新过程中,xcode将构建目标切换到模拟器.一旦我将目标切换回设备,它就会再次编译.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...