Skip to content

Add remove super view with dissolve animation #23

@Morbix

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

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