Skip to content

Add remove super view with dissolve animation #23

Description

@Morbix
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()
        }
    }
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions