花了挺久時間,終於通過google在stake overflow上找到了解決方式。
總結一下:重寫一個custom的segue,在storyboard的右邊設置segue爲custom,並設置其對應的class。
、
創建一個segue的類,繼承UIStoryboardSegue,代碼如下:
import UIKit
class SegueFromTop: UIStoryboardSegue {
override func perform()
{
let src = self.source
let dst = self.destination
src.view.superview?.insertSubview(dst.view, aboveSubview: src.view)
dst.view.transform = CGAffineTransform(translationX: 0, y: -src.view.frame.size.height)
UIView.animate(withDuration: 0.25,
delay: 0.0,
options: UIViewAnimationOptions.curveEaseInOut,
animations: {
dst.view.transform = CGAffineTransform(translationX: 0, y: 0)
},
completion: { finished in
src.present(dst, animated: false, completion: nil)
}
)
}
}