Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation on touch event #433

Open
phimage opened this issue Apr 4, 2017 · 2 comments
Open

Animation on touch event #433

phimage opened this issue Apr 4, 2017 · 2 comments

Comments

@phimage
Copy link
Member

phimage commented Apr 4, 2017

I want to animate views like UIButton when touching it.

For instance a scale when touching and an unscale when releasing.

Where to do it

We could override UIResponder functions touchesBegan, touchesMoved, touchesEnded, touchesCancelled or maybe register to UIControlEvents

An animation example

In touch Begin

UIView.animate(withDuration: duration,
                   delay: delay,
                   options: .curveEaseIn,
                   animations: {() -> Void in
                    view.transform = CGAffineTransform(scaleX: 0.85, y: 0.85)
                    view.alpha = 0.7
    },
                   completion: nil
)

In touch End or Cancel

    UIView.animate(withDuration: configuration.duration,
                   delay: configuration.delay,
                   options: .curveEaseIn,
                   animations: {() -> Void in
                    view.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
                    view.alpha = 1
    },
                   completion: nil
)

some conception idea

  • have an enum like AnimationType
  • have parameters for the animations
@tbaranes
Copy link
Member

tbaranes commented Apr 5, 2017

Looking forward to this! That will be an awesome feature 👍

@phimage phimage self-assigned this Apr 6, 2017
@tbaranes
Copy link
Member

Another idea of animation: https://github.com/BalestraPatrick/SquishButton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants