SpriteKit itself does not provide native UI controls like sliders, switches (toggles), or buttons in the way UIKit does. SpriteKit is a game and animation framework focused on 2D rendering and scene management, not general-purpose app UI.
Here we create custom, minimal version of stylable controls directly in SpriteKit with sprites and touches. We'll use custom artwork (for slider thumb positions and toggle states).
Use two SKSpriteNodes:
- One for the slider track.
- One for the thumb (movable handle).
Track touchesMoved to update the thumb’s position and value. You can decorate the track and thumb with any images you like.
Use two SKSpriteNodes:
- One for the normal start.
- One for the "toggled" state.
Respond to "mouse up inside" state to invert the toggle's state and value. You can customize what the normal and toggled state look like with your custom images.
