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://www.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>

        行唐县| 南丹县| 宁明县| 赣榆县| 嘉义市| 克拉玛依市| 诏安县| 石家庄市| 鸡西市| 高邑县| 广元市| 慈溪市| 巴林右旗| 驻马店市| 乌恰县| 顺平县| 雅安市| 上杭县| 台州市| 恩施市| 舞阳县| 屏东县| 舞阳县| 抚顺县| 扎鲁特旗| 天长市| 潜江市| 明星| 板桥市| 东乌珠穆沁旗| 高安市| 威远县| 朝阳市| 金华市| 沧源| 恩施市| 鲁甸县| 汨罗市| 林州市| 黔西| 陇南市|