Bubbles is a great new iOS picker written in Swift introduced with the Apple Music App.
Bubbles is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Bubbles"
To add a new Bubble picker, import Bubbles in your ViewController:
import Bubbles
Add a new view in your .XIB and set the class to CSBubblesView
Change Primary Color
and Secondary Color
from the Attributes Inspector
Connect your new picker through an @IBOutlet
@IBOutlet weak var bubblesView: CSBubblesView!
Finally, in your viewDidAppear
add the following
self.bubblesView.dataArray = NSMutableArray(array: ["Argentina", "Aruba", "Australia", "Austria", "Bahamas", "Barbados", "Belgium", "Belize", "Bermuda", "Brazil", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Dominican Republic", "Egypt", "Faroe Islands", "Fiji", "France", "Germany", "Greece"])
In order to retrive the values that were selected/deselected, use NSNotificationCenter
Add in your viewDidLoad
NotificationCenter.default.addObserver(self, selector: #selector(ViewController.bubbleWasSelected), name: NSNotification.Name(rawValue: "BubbleWasSelected"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(ViewController.bubbleWasDeselected), name: NSNotification.Name(rawValue: "BubbleWasDeselected"), object: nil)
And implement the methods:
func bubbleWasSelected(notification: NSNotification) {
print(notification.object as! String)
}
func bubbleWasDeselected(notification: NSNotification) {
print(notification.object as! String)
}
Cristina Sita, [email protected]
Bubbles is available under the MIT license. See the LICENSE file for more info.