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

Add remove super view with dissolve animation #23

Open
Morbix opened this issue Aug 20, 2016 · 0 comments
Open

Add remove super view with dissolve animation #23

Morbix opened this issue Aug 20, 2016 · 0 comments

Comments

@Morbix
Copy link
Member

Morbix commented Aug 20, 2016

enum UIViewFadeAnimation {
    case Up
    case Down
    case Left
    case Right
}

extension UIView {
    func fadeAnimationTo(direction:UIViewFadeAnimation, offSet: CGFloat) {
        let originalCenter = center
        UIView.animateWithDuration(2.0, delay: 0.0, options: .CurveLinear, animations: { () -> Void in

            self.alpha = 0.0

            switch direction {
            case .Up:
                self.center = CGPoint(x: originalCenter.x, y: originalCenter.y-offSet)
            case .Down:
                self.center = CGPoint(x: originalCenter.x, y: originalCenter.y+offSet)
            case .Left:
                self.center = CGPoint(x: originalCenter.x-offSet, y: originalCenter.y)
            case .Right:
                self.center = CGPoint(x: originalCenter.x+offSet, y: originalCenter.y)
            }

            }) { (finished) -> Void in
                self.removeFromSuperview()
        }
    }
}
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

1 participant