Skip to content

Instantly share code, notes, and snippets.

@Bogidon
Last active May 12, 2016 22:53
Show Gist options
  • Save Bogidon/8d02cdc1af2e453a59fa17e64072e9b2 to your computer and use it in GitHub Desktop.
Save Bogidon/8d02cdc1af2e453a59fa17e64072e9b2 to your computer and use it in GitHub Desktop.
Animate the reveal of a UIView from the leading side.
//
// UIView+RevealFromLeading.swift
// VitocDev
//
// Created by Bogdan Vitoc on 5/12/16.
// Copyright © 2016 VitocDev. All rights reserved.
//
import UIKit
extension UIView {
/**
Animate the reveal of a UIView from the leading side.
- parameter duration: duration of animation
- warning: Will overwrite any existing `maskViews`.
*/
func revealFromLeading(duration: NSTimeInterval) {
maskView = UIView(frame: CGRectMake(0,0,0, CGRectGetHeight(self.frame)))
maskView?.backgroundColor = .whiteColor()
UIView.animateWithDuration(duration) {
self.maskView?.frame.size.width = CGRectGetWidth(self.frame)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment