IOS視圖縮放顯示動畫效果

來源:互聯網
上載者:User

標籤:os   io   for   問題   代碼   時間   res   type   

效果:視圖從大--小縮放顯示/小--大 (只是比例問題)


方法1.直接show出view的時候:
把下面的這段代碼加到viewController或者view出現的時候就OK

  self.view.transform = CGAffineTransformMakeScale(1.0f, 1.0f);//將要顯示的view按照正常比例顯示出來
  [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
  [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  //InOut 表示進入和出去時都啟動動畫
  [UIView setAnimationDuration:0.5f];//動畫時間
  self.view.transform=CGAffineTransformMakeScale(0.01f, 0.01f);//先讓要顯示的view最小直至消失
  [UIView commitAnimations]; //啟動動畫
  //相反如果想要從小到大的顯示效果,則將比例調換
  //UIGraphicsGetCurrentContext  裡面東西很豐富。


——————————————————————————————————————————


方法2.push一個viewController時:
把下面的代碼加到push的方法裡面就OK
    CATransition *myTranstiton = [CATransition animation];
    myTranstiton.duration = 0.5;
    myTranstiton.type = kCATransitionFade;   
    //myTranstiton.subtype = kCATransitionFromTop;   
    [self.view.superview.layer  addAnimation:myTranstiton forKey:nil ];   
    MainViewController * _mainViewController=[[MainViewController alloc] init];
    [self presentModalViewController:_mainViewController animated:NO];

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.