Animated Social share buttons control for iOS written in Swift. This library is inspired AAShareBubbles.
I tried AAShareBubbles with Swift, it mostly worked. But I cannot use AAShareBubbles(Objective-c code) in protocol extension. So I created SwiftShareBubbles in pure Swift.
iOS 16.0 or later, written in Swift.
pod 'SwiftShareBubbles'SwiftRoutes is compatible with Carthage. Add it to your Cartfile:
github "takecian/SwiftShareBubbles"- Instantiate SwiftShareBubbles, specify center position and radius of Circle.
- Choose social buttons to be shown.
- Set delegate
- Call show method.
class ViewController: UIViewController, SwiftShareBubblesDelegate {
var bubbles: SwiftShareBubbles?
override func viewDidLoad() {
super.viewDidLoad()
bubbles = SwiftShareBubbles(point: CGPoint(x: view.frame.width / 2, y: view.frame.height / 2), radius: 100, in: view)
bubbles?.showBubbleTypes = [Bubble.twitter, Bubble.line, Bubble.safari]
bubbles?.delegate = self
}
// SwiftShareBubblesDelegate
func bubblesTapped(bubbles: SwiftShareBubbles, bubbleId: Int) {
if let bubble = Bubble(rawValue: bubbleId) {
print("\(bubble)")
switch bubble {
case .facebook:
break
case .twitter:
if SLComposeViewController.isAvailable(forServiceType: SLServiceTypeTwitter) {
guard let composer = SLComposeViewController(forServiceType: SLServiceTypeTwitter) else { return }
composer.setInitialText("test test")
present(composer, animated: true, completion: nil)
}
break
case .line:
break
default:
break
}
} else {
// custom case
}
}
func bubblesDidHide(bubbles: SwiftShareBubbles) {
}
@IBAction func buttonTapped(_ sender: Any) {
bubbles?.show()
}
}- LINE
- google plus
- Youtube
- Pintereset
- Safari
You can add custom icons as follows,
class ViewController: UIViewController, SwiftShareBubblesDelegate {
var bubbles: SwiftShareBubbles?
let customBubbleId = 100
override func viewDidLoad() {
super.viewDidLoad()
...
let customAttribute = ShareAttirbute(bubbleId: customBubbleId, icon: UIImage(named: "Custom")!, backgroundColor: UIColor.white)
bubbles?.customBubbleAttributes = [customAttribute]
bubbles?.delegate = self
}
func bubblesTapped(bubbles: SwiftShareBubbles, bubbleId: Int) {
if customBubbleId == bubbleId {
// custom case
print("custom tapped")
}
}
}MIT
Use a maintained Ruby (3.3 or newer recommended) and the Bundler version recorded
in Gemfile.lock. Run bundle install and invoke CocoaPods with bundle exec pod.
See the dependency security review for toolchain
constraints, security scope, and macOS validation commands.

