ios Sprite Kit screengrab?

后端 未结 4 663
小蘑菇
小蘑菇 2020-12-04 22:28

I am trying to get a screen grab of a view that has a SKScene in it. The technique I am using is:

UIGraphicsBeginImageContextWithOptions(self.view.bounds.si         


        
4条回答
  •  余生分开走
    2020-12-04 22:55

    As a faster alternative, you can use the textureFromNode method on SKView, which returns an image of the view as an SKTexture. Simply pass the SKScene as the argument:

    let texture = skView.textureFromNode(scene)
    

    Or to capture part of the scene:

    let texture = skView.textureFromNode(scene, crop: cropRect)
    

提交回复
热议问题