Latest 0.2.0
Homepage https://github.com/takecian/SwiftShareBubbles
License MIT
Platforms ios 8.0
Authors

Version
License
Platform
Carthage compatible

Animated Social share buttons control for iOS written in Swift.
This library is inspired AAShareBubbles.

ShareBubbles1

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.

Requirements

iOS 8.0 or later, written in Swift3.

Installation

Cocoapods

pod 'SwiftShareBubbles'

Carthage

SwiftRoutes is compatible with Carthage. Add it to your Cartfile:

github "takecian/SwiftShareBubbles"

Usage

  1. Instantiate SwiftShareBubbles, specify center position and radius of Circle.
  2. Choose social buttons to be shown.
  3. Set delegate
  4. 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()
    }
}

ShareBubbles2

Supported buttons

  • facebook
  • Twitter
  • LINE
  • google plus
  • Youtube
  • Instagram
  • Pintereset
  • Whatsapp
  • Linkedin
  • Weibo
  • Safari

Custom icons

You can add custom icons as follows,

    override func viewDidLoad() {
        super.viewDidLoad()
        ...
        let customBubbleId = 100
        let customAttribute = ShareAttirbute(bubbleId: customBubbleId, icon: UIImage(named: "Custom")!, backgroundColor: UIColor.white)
        bubbles?.customBubbleAttributes = [customAttribute]
    }

     func bubblesTapped(bubbles: SwiftShareBubbles, bubbleId: Int) {
        if customBubbleId == bubbleId {
            // custom case
            print("custom tapped")
        }
    }

License

MIT

Latest podspec

{
    "name": "SwiftShareBubbles",
    "version": "0.2.0",
    "summary": "Animated Social share buttons control for iOS written in Swift.",
    "description": "Animated Social share buttons control for iOS written in Swift. This library is inspired AAShareBubbles.",
    "homepage": "https://github.com/takecian/SwiftShareBubbles",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "takecian": "[email protected]"
    },
    "source": {
        "git": "https://github.com/takecian/SwiftShareBubbles.git",
        "tag": "0.2.0"
    },
    "social_media_url": "https://twitter.com/takecian",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SwiftShareBubbles/**/*",
    "resource_bundles": {
        "SwiftShareBubbles": [
            "SwiftShareBubbles/SwiftShareBubbles.bundle"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This