Latest 0.1.1
License MIT
Platforms ios 8.0
Frameworks UIKit



ScalingGradientAnimatedButton is a subclass of UIView, written is Swift, that encloses a gradient and a scale animation in a view.


You can see those buttons in the iOS App: ‘A Complex Calc’:


To run the example project, clone the repo, and run pod install from the Example directory first.


  • iOS 8
  • Swift 4.0


ScalingGradientAnimatedButton is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'ScalingGradientAnimatedButton'


Four inizialization functions are included to provide enough customization.

import ScalingGradientAnimatedButton

/// then inside the viewDidLoad or any view controller with a reference to the view

// init the button with two different colors for the selected and the unselected state, their transition can be animated or not
button.initButton(opacity: 1.0, color:, selectedColor: UIColor.cyan, buttonScale: 0.6, animationDuration: 0.5, shadowOpacity: 0.4, shadowRadius: 1.0, shouldHaveSelectedColorAnimation: true)

// init the button with just one color, only the scale will be animated
button.initButton(opacity: 1.0, color: UIColor.cyan, buttonScale: 1.3, animationDuration: 0.5, shadowOpacity: 0.6, shadowRadius: 1.0)

Set the position of the button to anchor its animation

button.buttonPosition = .left

To intercept events arriving on the button assign this closure, it pass the tag of the view as a parameter. You can set the tag from ther storyboard

button.calculatorButtonEvent = { tag in
  print("Tap or long press received")


Antonio Ruffolo


ScalingGradientAnimatedButton is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "ScalingGradientAnimatedButton",
    "version": "0.1.1",
    "summary": "A subview of UIView that provide a custom Button with a gradient and scale animation",
    "description": "TODO: 'This class provides a view that can be used as UIButton. Anonimous callbacks return the tag of the view when tap and longnpress events are fired. The view can be initialized prvoviding a gradient colors and positions for the unselected state and for the selected state. A scale parameter also isnused to device if the view should increase or decrease his size, giving it a 'moving forward' or 'moving backward' illusion.nA second init function provided just an unselected and selected color.nAn enum is used to let the user choose a margin to which the button should stick while moving (if any)'na subclass of UIView custom button with scale gradient 3D like animation",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Antonio Ruffolo": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.1"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0"
    "source_files": "ScalingGradientAnimatedButton/Classes/**/*",
    "frameworks": "UIKit",
    "pushed_with_swift_version": "4.0.3"

Pin It on Pinterest

Share This