1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      iOSswift實(shí)現(xiàn)轉(zhuǎn)場動畫的方法示例

      轉(zhuǎn)場動畫介紹

      成都創(chuàng)新互聯(lián)公司是一家專注于網(wǎng)站建設(shè)、成都做網(wǎng)站與策劃設(shè)計(jì),威遠(yuǎn)網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)10多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:威遠(yuǎn)等地區(qū)。威遠(yuǎn)做網(wǎng)站價(jià)格咨詢:18980820575

      轉(zhuǎn)場動畫在我們?nèi)粘i_發(fā)中是經(jīng)常遇到的,所謂轉(zhuǎn)場動畫,就是一個(gè)控制器的view切到另一個(gè)控制器的view上過程中過的動畫效果。本例子是實(shí)現(xiàn)了在導(dǎo)航控制器的titleView邊上慢慢彈出一個(gè)控制器。下面話不多說,來一起看看詳細(xì)的介紹:

      效果圖:

      iOS swift實(shí)現(xiàn)轉(zhuǎn)場動畫的方法示例
      專場前

      iOS swift實(shí)現(xiàn)轉(zhuǎn)場動畫的方法示例
      專場后

      示例代碼

      首先自定義一個(gè)animator類。在需要轉(zhuǎn)場的控制器內(nèi),設(shè)置代理

       //需要設(shè)置轉(zhuǎn)場動畫的控制器titleViewVc.transitioningDelegate = aniamator//這里的animator是animator的實(shí)例

      下面是animator類中的代碼

      class animatorTool: NSObject {
       lazy var isPresent = false
       var callBack : ((isPresented:Bool)->())?//向外界傳遞動畫是否正在顯示
      
       init(callBack : ((isPresented:Bool)->())) {
        self.callBack = callBack
       }//自定義構(gòu)造方法,便于給閉包賦值
      }
      extension animatorTool:UIViewControllerTransitioningDelegate{
       func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {
        return AWYPresentationController(presentedViewController: presented, presentingViewController: presenting)//AWYPresentationController是自定義繼承自UIPresentationController的類,是為了設(shè)置modal出來的vc的view的大小
       }
       func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        isPresent = true
        self.callBack!(isPresented: isPresent)
        return self
       }
      
       func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        isPresent = false
        self.callBack!(isPresented: isPresent)
        return self
       }
      }
      
      extension animatorTool:UIViewControllerAnimatedTransitioning{
       func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
        return 0.5//動畫時(shí)長
       }
       func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        isPresent ?animatetransitionForPresented(transitionContext) : animatetransitionForDismissed(transitionContext)
       }
      
       func animatetransitionForPresented(transitonContext:UIViewControllerContextTransitioning){
        let aimView = transitonContext.viewForKey(UITransitionContextToViewKey)!
        transitonContext.containerView()?.addSubview(aimView)
      
        aimView.transform = CGAffineTransformMakeScale(1.0, 0.0)
        UIView.animateWithDuration(transitionDuration(transitonContext), animations: {
         aimView.layer.anchorPoint = CGPointMake(0.5, 0.0)
         aimView.transform = CGAffineTransformIdentity
        }) { (_) in
         transitonContext.completeTransition(true)
        }
       }
      
       func animatetransitionForDismissed(transitonContext:UIViewControllerContextTransitioning){
        let aimView = transitonContext.viewForKey(UITransitionContextFromViewKey)!
        transitonContext.containerView()?.addSubview(aimView)
      
      
        UIView.animateWithDuration(transitionDuration(transitonContext), animations: {
         aimView.layer.anchorPoint = CGPointMake(0.5, 0.0)
         aimView.transform = CGAffineTransformMakeScale(1.0, 0.001)//留一點(diǎn)值,這樣會有動畫效果
        }) { (_) in
         transitonContext.completeTransition(true)
        }
      
       }
      
      
      }

      總結(jié)

      以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對創(chuàng)新互聯(lián)的支持。


      新聞名稱:iOSswift實(shí)現(xiàn)轉(zhuǎn)場動畫的方法示例
      標(biāo)題URL:http://ef60e0e.cn/article/jhohje.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        凤凰县| 隆尧县| 涿州市| 天柱县| 宜兰市| 太和县| 苗栗市| 屏山县| 苏尼特右旗| 巴塘县| 浙江省| 政和县| 简阳市| 泰来县| 赤壁市| 拉孜县| 石渠县| 台湾省| 永德县| 筠连县| 二连浩特市| 大连市| 隆安县| 赞皇县| 临沭县| 沙洋县| 射洪县| 云南省| 中牟县| 宝丰县| 琼结县| 阳原县| 沐川县| 尉犁县| 新乡县| 河曲县| 怀集县| 临沧市| 湄潭县| 禹州市| 赤城县|