Với mỗi Thực hiện kim loại dựa ImageView tôi đang phải đối mặt với cùng một vấn đềkim loại 'kết cấu' không tìm thấy
let targetTexture = currentDrawable?.texture else{ return }
Giá trị của loại 'MTLDrawable' không có thành viên 'kết cấu'
Có vẻ như táo đã thay đổi một số kim loại api
đây là chức năng đầy đủ Tôi đang dùng thử:
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()
}
Hiển thị khai báo và gán biến 'currentDrawable' của bạn. Theo lỗi, đó là loại 'MTLDrawable' mà không, trên thực tế, có một thuộc tính' texture'. Tôi tưởng tượng bạn đang nghĩ đến 'CAMetalDrawable' –
@KenThomases nhưng trong mọi triển khai Chế độ xem bộ kim loại được thực hiện theo cách này và không có cách nào để gọi CAMetalDrawable từ MTLDrawable –
Bạn đang triển khai lớp con của 'MTKView'? –