当前位置: 首页 > 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/56932/

相关文章:

  • 一个网站上能不能放两个域名 两个备案号拉新平台
  • 福州电子网站建设产品开发流程表
  • 国外交互设计网站欣赏35个成功的市场营销策划案例
  • 每年网站备案抽查网页制作常用的技术有哪些
  • 崇明网站开发wordpress中文工具箱
  • 网站建设费按几年摊销品牌营销包括哪些内容
  • 网站运营工作内容网站建设模板删不掉
  • 网站建设 更新 维护二手交易网站开发的
  • 滨海做网站哪家好wordpress国内加速
  • 合浦县建设局网站管理咨询公司取名
  • 无锡建设教育协会网站建设网站不用模板可以吗
  • 高校官方网站建设wordpress的编辑器
  • 国外建站企业图片短链接生成器
  • 文具用品网站设计规划书免费建网站的平台
  • 专做土特产的网站设计装修公司哪家好
  • 网站内做全文搜索陕西营销型手机网站
  • 可以分销的平台网站seo优化书籍
  • 计算机网站开发是那个语言如何查询一个网站是那家公司做的
  • 网站专题制作原则wordpress图标
  • 网站不支持m.域名wordpress弹
  • 重庆网站建设哪个平台好排行网站模板
  • 100件创意产品设计国外西安稳定的seo
  • 上海手机网站建设报价表建设部网站怎么查询企业业绩
  • 网站建设服务面试题开源门户网站
  • 哪些网站做的最好销售怎么找客户
  • 诚信通网站怎么做wordpress 文章的各种调用
  • 在线网站地图生成器wordpress特效插件
  • 网站建设维护保密协议书灯光设计网站推荐
  • 网站前端代码模板python 网站开发 普及
  • iis网站ip网页设计师相关职业前景