Giter Club home page Giter Club logo

popbouncebutton's Introduction

PopBounceButton

Swift-Version CocoaPods license CocoaPods

About

A customizable animated button built with Facebook's Pop animation library. Inspired by the familiar button stack from Tinder.

Features

  • Lightweight and highly customizable
  • Animations for multiple UIControlEvents
  • Pure Swift 4

Example

To run the example project, clone the repo and run the PopBounceButton-Example target.

TinderDemo

MessageButtonExample

Requirements

  • iOS 9.0+
  • Xcode 9.0+
  • Swift 4.0+

Installation

CocoaPods

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

pod 'PopBounceButton'

Manual

  1. Download and drop the PopBounceButton directory into your project.
  2. Install Facebook's Pop library.

Contributing

  • If you found a bug, open an issue and tag as bug.
  • If you have a feature request, open an issue and tag as feature.
  • If you want to contribute, submit a pull request.
    • In order to submit a pull request, please fork this repo and submit a pull request from your forked repo.
    • Have a detailed message as to what your pull request fixes/enhances/adds.

Quick Start

  1. Add a PopBounceButton to your view.

    let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100))
    let button = PopBounceButton(frame: frame)
    view.addSubview(button)
  2. Attach a target to your button to handle any events.

    button.addTarget(self, action: #selector(handleTap), for: .touchUpInside)
    @objc func handleTap(_ sender: PopBounceButton) {
        //do something
    }

Customization

Because PopBounceButton is a subclass of UIButton, it can be customized in the same way. The button's animations can be changed by modifying the following variables exposed by PopBounceButton:

var springBounciness: CGFloat = 19.0
var springSpeed: CGFloat = 10.0
var springVelocity: CGFloat = 6.0

var cancelTapScaleDuration: TimeInterval = 0.3

var longPressScaleFactor: CGFloat = 0.7
var longPressScaleDuration: TimeInterval = 0.1
var minimumPressDuration: TimeInterval = 0.2

Sources

  • Pop: Facebook's iOS animation framework.

Author

Mac Gallagher, [email protected]

License

PopBounceButton is available under the MIT License, see LICENSE for more infomation.

popbouncebutton's People

Contributors

mac-gallagher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

popbouncebutton's Issues

PopBounceButton with UIViewRepresentable is not work in SwiftUI

Hi thanks for this library. Is it possible to use this in SwiftUI in a way?

`struct myBounceButton: UIViewRepresentable{
    func makeUIView(context: Context) -> PopBounceButton {
        let  myBtn = PopBounceButton()
        myBtn.setTitle("click me", for: .normal)
        myBtn.setTitleColor(UIColor.white, for: .normal)
        myBtn.layer.backgroundColor = UIColor.red.cgColor
        myBtn.layer.cornerRadius = 16
        return myBtn
    }
    func updateUIView(_ uiView: PopBounceButton, context: Context) {
        
    }
}`

I would expect to work this piece code but animation is broken

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.