我将 UIView 添加到 MTKView 并在 MTKViewDelegate 的 DRAW 委托方法中为 UIView 设置动画。
这个动画会由 GPU/Metal 处理吗?动画应该更流畅还是和我使用 UIView.animate 一样?
func draw(in view: MTKView) {
let newdescriptor = self.metalview.currentRenderPassDescriptor
let commandbuffer = self.metalqueue.makeCommandBuffer()
let commandencoder = commandbuffer?.makeRenderCommandEncoder(descriptor: newdescriptor!)
// //////////////////////////// //
timer += 0.01
var currenttime = sin(timer)
uiviewbox.transform = CGAffineTransform(rotationAngle: CGFloat(sin(timer)))
// //////////////////////////// //
commandencoder?.endEncoding()
let thedrawable = self.metalview.currentDrawable
commandbuffer?.present(thedrawable!)
commandbuffer?.commit()
}