Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class SlideOverSegue: UIStoryboardSegue {
- override func perform() {
- let firstView = self.sourceViewController.view as UIView!
- let secondView = self.destinationViewController.view as UIView!
- let screenSize = UIScreen.mainScreen().bounds.size
- let window = UIApplication.sharedApplication().keyWindow
- secondView.frame = CGRectMake(0.0, screenSize.height, screenSize.width, screenSize.height)
- window?.insertSubview(secondView, aboveSubview: firstView)
- firstView.layer.anchorPoint = CGPoint(x: 0.0, y: 0.0)
- firstView.layer.position = CGPoint(x: 0.0, y: 0.0)
- UIView.animateWithDuration(2, delay: 0, options: .CurveEaseInOut, animations: {
- print(firstView.frame)
- let offset: CGFloat = 25
- let offsetX = 2 * (offset / firstView.frame.width)
- let offsetY = 2 * (offset * (firstView.frame.height / firstView.frame.width) / firstView.frame.height)
- let transform = CGAffineTransformScale(CGAffineTransformIdentity, 1 - offsetX, 1 - offsetY)
- firstView.transform = transform
- firstView.layer.position = CGPoint(x: offset, y: offset)
- }, completion: nil)
- UIView.animateWithDuration(5, delay: 0.05, options: .CurveEaseOut, animations: {
- secondView.frame = CGRectMake(0.0, 0.0, screenSize.width, screenSize.height)
- }) { finished -> Void in
- self.sourceViewController.presentViewController(self.destinationViewController, animated: false, completion: nil)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement