随着每个基于@R_404_338@l的
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将构建目标切换到模拟器.一旦我将目标切换回设备,它就会再次编译.