/BubbleButton

BubbleButton is a Swift 3 UIButton subclass which produces fancy bubbles when it's tapped.

Primary LanguageSwiftMIT LicenseMIT

BubbleButton

BubbleButton is a Swift 3 UIButton subclass which produces fancy bubbles when it's tapped.

N|Solid

Installation

CocoaPods

pod 'BubbleButton', '~> 0.1.1'

Manually

Just download or clone the repo and move BubbleButton.swift file to your project.

Usage

Interface Builder

In Interface Builder you can set BubbleButton to Custom Class property of your button. Just do not forget the module field. Then you can customize its properties.

N|Solid

By Code

button = BubbleButton(frame: CGRect(x: 0, y: 0, width: 200, height: 50))
button.backgroundColor = UIColor.gray
button.bubbleColor = UIColor.red
button.bubbleCount = 5
..
self.view.addSubview(button)

Starting and Ending Animation

You can start animating button after it's tapped. After your progress is completed you can call "endAnimationWith" to reset button state.

@IBAction func buttonAction(_ sender: AnyObject) {
    bubbleButton.startBubbleAnimationWith(direction: .TopRight)
    print("startingAnimation")
    
    DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
        print("endingAnimation")
        
        self.bubbleButton.endAnimationWith {
            print("animationIsEnded")
        }
    }
}

Customize

You can customize these properties in Interface Builder or by code:

Properties

titleForProgress:String
titleForCompletion:String
    
endAnimationDuration:Float
fadeOutAnimationDelay:Float
fadeOutAnimationDuration:Float
    
bubbleColor:UIColor
bubbleCount:Int
    
bubbleSpeedMin:CGFloat
bubbleSpeedMax:CGFloat
    
bubbleRadiusMin:CGFloat
bubbleRadiusMax:CGFloat

Direction

direction argument of startBubbleAnimationWithdetermines where bubbles move to.

public enum BubbleDirection
{
    case Top
    case Left
    case Bottom
    case Right
    
    case TopLeft
    case TopRight
    case BottomLeft
    case BottomRight
}

License

MIT

Free Software, Hell Yeah!