A view that enables you to display an AR experience with SpriteKit.


class ARSKView : SKView


Use the ARSKView class to create augmented reality experiences that position 2D elements in 3D space within a device camera view of the real world. When you run the view's provided ARSession object:

  • The view automatically renders the live video feed from the device camera as the scene background.

  • When you implement ARSKViewDelegate methods to associate SpriteKit content with real-world positions, the view automatically scales and rotates those SpriteKit nodes so that they appear to track the real world seen by the camera.


First Steps

Providing 2D Virtual Content with SpriteKit

Use SpriteKit to place two-dimensional images in 3D space in your AR experience.

var session: ARSession

The AR session that manages motion tracking and camera image processing for the view's contents.

Responding to AR Updates

var delegate: ARSKViewDelegate?

An object you provide to mediate synchronization of the view's AR scene information with SpriteKit content.

protocol ARSKViewDelegate

Methods you can implement to mediate the automatic synchronization of SpriteKit content with an AR session.

Finding Real-World Surfaces

func hitTest(CGPoint, types: ARHitTestResult.ResultType) -> [ARHitTestResult]

Searches for real-world objects or AR anchors in the captured camera image corresponding to a point in the SpriteKit view.

Mapping Content to Real-World Positions

func anchor(for: SKNode) -> ARAnchor?

Returns the AR anchor associated with the specified SpriteKit node, if any.

func node(for: ARAnchor) -> SKNode?

Returns the SpriteKit node associated with the specified AR anchor, if any.

See Also


class ARView

A view that enables you to display an AR experience with RealityKit.

class ARSCNView

A view that enables you to display an AR experience with SceneKit.