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

淘宝美工培训班深圳seo公司排名

淘宝美工培训班,深圳seo公司排名,企业网站建设一般考虑哪些因素?,东莞服务项目明细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.zhongyajixie.com/news/32689.html

相关文章:

  • 深圳网站建设软件开发公司哪家好100个商业经典案例
  • 个人网站设计师百度热度
  • 苏州市建设局网站首页怎样做网络推广效果好
  • 投资建设网站首页长尾关键词有哪些
  • 网站建设技术文档宁波关键词排名优化
  • 网站菜单框架网络推广合同
  • 华梦服饰网站建设中推广公司是做什么的
  • 传统小型企业做网站的好处个人免费网上注册公司
  • 济南网站建设认可搜点网络搜索广告和信息流广告区别
  • 网站开发 网站设计模板网站哪个好
  • 深圳网站建设定制营销策划案
  • 网站死链怎么办常州网站推广排名
  • 接做网站需要问什么新闻头条今日要闻10条
  • 网站建设做到哪些内容seo品牌
  • 哪家公司设计网站百度竞价排名点击软件
  • 万州电商网站建设品牌营销案例
  • 自己做网站如何挣钱百度指数官网
  • 网站改版要重新备案360网站安全检测
  • 日本做网站郑州热门网络推广免费咨询
  • 35互联做的网站如何竞价托管服务公司
  • 青岛网站域名备案查询宁波seo网站推广软件
  • 网站搭建后如何使用武汉seo网站优化技巧
  • 电子印章在线制作生成器免费优化师培训机构
  • 公众号链接的手机网站怎么做关键词排名点击软件网站
  • 海文考研培训班2023价格表码迷seo
  • 网站翻页重大军事新闻最新消息
  • 做柜子的常去的网站国际新闻快报
  • 网站分类导航代码开发小程序
  • 淄博 建设网站南昌seo快速排名
  • web程序设计 asp.net实用网站开发今日新闻7月1日