Is it possible to resize a metal view (MTKView()) so its height stretches out the whole screen but the ratio to the width is maintained?

I am trying to scale my MTKView() full screen on an iPhone X and I want to maintain the ratio in regards to the widht (I understand that means that some of the side will be cut off).


Can anyone help please?


Thats what I am currently doing:

required init(coder: NSCoder) {
        super.init(coder: coder)
        
        device = MTLCreateSystemDefaultDevice()
        
        configureMetal()
        
        createTextureCache()
        
        colorPixelFormat = .bgra8Unorm
        
        self.framebufferOnly = false
        self.autoResizeDrawable = false
        self.contentMode = .scaleAspectFit
        self.contentScaleFactor = UIScreen.main.scale
        self.drawableSize = CGSize(width: 2320, height: 3088)
    }
Post not yet marked as solved Up vote post of rmeinl Down vote post of rmeinl
1.6k views