Reputation: 1
So currently I'm coding an app, and I want to segue from one view to a new view, but every time I use the segue the old view is seen in the background of the new view, like so.
It should also be noted that on the simulator I can just drag downward and the view goes away, I don't really want this to happen either.
On the storyboard for the attributes inspector, I'm using identifier: FadeSegue, class: FadeSegue, Selector: none, and Kind: Custom
Here's what the code implementing the segue looks like: In the viewDidLoad function:
let cTap = UITapGestureRecognizer(target: self, action: #selector(shiftView(_:)))
view.addGestureRecognizer(cTap)
the shiftView function:
@objc func shiftView(_ sender: UITapGestureRecognizer)
{
performSegue(withIdentifier: "FadeSegue", sender: nil)
}
Then the FadeSegue animation code (I'm pretty sure the issue doesn't come from this)
import UIKit
class FadeSegue: UIStoryboardSegue {
override func perform() {
let source = self.source
let destination = self.destination
let transition = CATransition()
transition.type = CATransitionType.fade
transition.duration = 0.7
source.view.window?.layer.add(transition, forKey: kCATransition)
source.present(destination, animated: false, completion: nil)
}
}
Please let me know if you guys see anything wrong.
With this code I was expecting the new view to simply completely replace the old view by fading in. The fade animation does work, but you can still see the old view behind the new one, and you can still swipe down to get rid of the new view.
Upvotes: 0
Views: 31