自定义segue的方向
花了挺久时间,终于通过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)
}
)
}
}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
