Last active
May 12, 2016 22:53
-
-
Save Bogidon/8d02cdc1af2e453a59fa17e64072e9b2 to your computer and use it in GitHub Desktop.
Animate the reveal of a UIView from the leading side.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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