A similar library for Android made by Irina Galata can be found here
To run the example project, clone the repo, and run pod install
from the Example directory first.
Version 1.0 of this library has undergone a comeplete rewrite and will require significant changes to your codebase if you were using the previous version. It now uses a delegate based architecture rather than the previous version which required closures.
BubblePicker requires a deployment target of atleast iOS 9.0 for UIKitDynamics and Swift 4.
Setup the BubblePicker view
let arr = ["TV Shows", "Sports", "Technology", "Science", "People", "Places", "Music", "Photography"]
bubblePicker = BubblePicker() // Or use a storyboard
bubblePicker.delegate = self;
bubblePicker.reloadData();
Implement the delegate methods
extension ViewController: BubblePickerDelegate {
func numberOfItems(in bubblepicker: BubblePicker) -> Int {
return items.count;
}
func bubblePicker(_: BubblePicker, nodeFor indexPath: IndexPath) -> BubblePickerNode {
let node = BubblePickerNode(title: items[indexPath.item], color: UIColor.red, image: UIImage());
return node;
}
}
Delegate callbacks for when a user selects or deselects a bubble
func bubblePicker(_: BubblePicker, didSelectNodeAt indexPath: IndexPath) {
}
func bubblePicker(_: BubblePicker, didDeselectNodeAt indexPath: IndexPath) {
}
Set and get selected nodes
bubblePicker.setSelected([0, 2, 3, 4]);
bubblePicker.getSelected();
Bubble picker node properties
public var font: UIFont = UIFont(name: "Avenir-Heavy", size: 14)!
public var selectedFont: UIFont = UIFont(name: "Avenir", size: 22)!
public var textColor: UIColor = UIColor.white
BubblePicker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "BubblePicker"
Ronnel Davis: [email protected]
BubblePicker is available under the MIT license. See the LICENSE file for more info.
Copyright (c) 2018 Ronnel Davis