- July 26, 2025
- Mins Read
Magnetic is a customizable bubble picker like the Apple Music genre selection.
$ pod try Magnetic
A Magnetic
object is an SKScene.
To display, you present it from an SKView object.
import Magnetic
class ViewController: UIViewController {
var magnetic: Magnetic?
override func loadView() {
super.loadView()
let magneticView = MagneticView(frame: self.view.bounds)
magnetic = magneticView.magnetic
self.view.addSubview(magneticView)
}
}
var magneticDelegate: MagneticDelegate? // magnetic delegate
var allowsMultipleSelection: Bool // controls whether you can select multiple nodes. defaults to true
var selectedChildren: [Node] // returns selected chidren
A Node
object is a SKShapeNode subclass.
// add circular node
let node = Node(text: “Italy”, image: UIImage(named: “italy”), color: .red, radius: 30)
magnetic.addChild(node)
// add custom node
let node = Node(text: “France”, image: UIImage(named: “france”), color: .blue, path: path, marginScale: 1.1)
magnetic.addChild(node)
// remove node
node.removeFromParent()
var text: String? // node text
var image: UIImage? // node image
var color: UIColor // node color
override func selectedAnimation() {
// override selected animation
}
override func deselectedAnimation() {
// override deselected animation
}
override func removedAnimation(completion: @escaping () -> Void) {
// override removed animation
}
The MagneticDelegate
protocol provides a number of functions for observing the current state of nodes.
func magnetic(_ magnetic: Magnetic, didSelect node: Node) {
// handle node selection
}
func magnetic(_ magnetic: Magnetic, didDeselect node: Node) {
// handle node deselection
}
Subclass the Node for customization.
For example, a node with an image by default:
class ImageNode: Node {
override var image: UIImage? {
didSet {
texture = image.map { SKTexture(image: $0) }
}
}
override func selectedAnimation() {}
override func deselectedAnimation() {}
}
To install with CocoaPods, simply add this in your Podfile
:
use_frameworks!
pod “Magnetic”
To install with Carthage, simply add this in your Cartfile
:
github “efremidze/Magnetic”
NavigationKit is a lightweight library which makes SwiftUI navigation super easy to use. 💻 Installation 📦 Swift Package Manager Using Swift Package Manager, add ...
An alternative SwiftUI NavigationView implementing classic stack-based navigation giving also some more control on animations and programmatic navigation. NavigationStack Installation ...
With SwiftUI Router you can power your SwiftUI app with path-based routing. By utilizing a path-based system, navigation in your app becomes ...
This package takes SwiftUI's familiar and powerful NavigationStack API and gives it superpowers, allowing you to use the same API not just ...