当前位置: 首页 > news >正文

深圳公司网站设计引航博景做的网站

深圳公司网站设计,引航博景做的网站,网站开发合同属于知识产权类吗,黄骅贴吧李官庄刘婷UINavigationController内部页面跳转默认为左右切换,但是当我们想向上弹出进入界面,或者向下离开界面时,需要实现UINavigationControllerDelegate 协议自行控制页面的动画(否则直接在navVc上叠加动画会导致动画结束后的那个页面,自…

UINavigationController内部页面跳转默认为左右切换,但是当我们想向上弹出进入界面,或者向下离开界面时,需要实现UINavigationControllerDelegate 协议自行控制页面的动画(否则直接在navVc上叠加动画会导致动画结束后的那个页面,自动加了异常动画),本文介绍这个实现方案。

定义一个类实现 UIViewControllerAnimatedTransitioning协议,实现下面的函数:


class NavigationControllerAnimation: NSObject, UIViewControllerAnimatedTransitioning {let operation: UINavigationController.Operationinit(operation: UINavigationController.Operation) {self.operation = operationsuper.init()}//页面过渡动画时间 func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {return 0.3}//加页面过渡的动画public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {guard let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from),let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) else { return }let containerView = transitionContext.containerViewif operation == .push {// do your animation for pushtoViewController.view.frame = containerView.bounds.offsetBy(dx: 0, dy: containerView.frame.size.height)fromViewController.view.frame = containerView.boundscontainerView.addSubview(toViewController.view)UIView.animate(withDuration: transitionDuration(using: transitionContext),delay: 0,options: [ UIView.AnimationOptions.curveEaseOut ],animations: {toViewController.view.frame = containerView.bounds},completion: { (finished) intransitionContext.completeTransition(true)})} else if operation == .pop {// do your animation for popcontainerView.addSubview(toViewController.view)containerView.addSubview(fromViewController.view)//containerView 上加的view在动画结束后一段时间后被释放了fromViewController.view.frame  = containerView.bounds
//            toViewController.view.frame = containerView.boundsUIView.animate(withDuration: transitionDuration(using: transitionContext),animations: {fromViewController.view.frame = containerView.bounds.offsetBy(dx: 0, dy: containerView.frame.size.height)},completion: { (finished) intransitionContext.completeTransition(true)})}}
}

UINavigationController 添加delegate


class BaseNavigationController: UINavigationController {override func viewDidLoad() {super.viewDidLoad()self.delegate = self}
}

实现delegate的协议 ,返回本文最开始定义的类的对象,这里只要返回nil 就会是默认的动画方式(所以可以按照需求切换界面过渡动画)

extension BaseNavigationController : UINavigationControllerDelegate {func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {return NavigationControllerAnimation(operation: operation)  }}

参考:
https://stackoverflow.com/questions/2215672/how-to-change-the-push-and-pop-animations-in-a-navigation-based-app

http://www.yayakq.cn/news/975022/

相关文章:

  • 网站怎么免费注册微信小程序开发怎么做
  • 设计站杭州建设网 工程信息网站
  • 门户网站开发使用什么语言wordpress建多个网站
  • 建设网站费用计入什么费用网站建设多少钱宋柯
  • 中国十大旅游网站濮阳做网站星月网络
  • 诸城 建设外贸网站赣州人才网官方网站
  • 网站内容与目录结构南通网站建设教程
  • 推广网站案例东莞横沥电子厂
  • 阳谷网站开发jquery 显示wordpress
  • 怎么优化网站源码关键词成都住建平台app
  • 建站网页建设网站开发需解决什么问题
  • 可商用图片素材网站网站顶部轮播怎么做
  • 大型网站制作小程序校园网页制作模板
  • 绍兴金圣建设有限公司网站在海南注册公司需要多少钱
  • 网站建设合同 文库做购物网站需要什么资质
  • 金安合肥网站建设专业平面设计图案
  • 怎么提高网站权重大连企业建设网站
  • 24什么网站建设哪个网站教做西餐
  • 河南便宜网站建设百度推广是怎么做的
  • cms网站开发流程虚拟电脑主机平台
  • 用jsp做肯德基的网站做网站 免费字体
  • 搜索引擎网站推广怎么做网站建设制作设计营销 广州
  • 制作汽车网站黄浦专业做网站
  • 网站开发问题论文网站开发属于软件设计嘛
  • 网站如何吸引蜘蛛酒店网站建设哪家好
  • 12306网站很难做吗wordpress产品优惠
  • 做平面设计必看的网站自己怎么做搬家网站
  • 长沙seo建站wordpress制作列表页
  • 建设京东物流网站的目标是什么石家庄网站优化公司
  • 怎么建设一个区块链资讯网站广州网站设计推荐刻