BubbleButton is a Swift 3 UIButton subclass which produces fancy bubbles when it's tapped.
pod 'BubbleButton', '~> 0.1.1'
Just download or clone the repo and move BubbleButton.swift file to your project.
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.
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)
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")
}
}
}
You can customize these properties in Interface Builder or by code:
titleForProgress:String
titleForCompletion:String
endAnimationDuration:Float
fadeOutAnimationDelay:Float
fadeOutAnimationDuration:Float
bubbleColor:UIColor
bubbleCount:Int
bubbleSpeedMin:CGFloat
bubbleSpeedMax:CGFloat
bubbleRadiusMin:CGFloat
bubbleRadiusMax:CGFloat
direction argument of startBubbleAnimationWith
determines where bubbles move to.
public enum BubbleDirection
{
case Top
case Left
case Bottom
case Right
case TopLeft
case TopRight
case BottomLeft
case BottomRight
}
MIT
Free Software, Hell Yeah!