2016-02-02 59 views
0

我有一個警告框,並想申請以下動畫「出現」,當它:動畫的警告框

Scale From 0.94 to 1.0 
Opacity From 0 to 1 
Time 0.50ms 
x1: 0.48, y1: 0.44, x2: 0.01, y2: 1.2 

如何在迅速實現這一目標導向的人?

代碼:

self.view.alpha = 0  
UIView.animateWithDuration(0.05, 
       animations: {() -> Void in 
        self.view.alpha = 1.0 
       }, 

感謝。

回答

1
self.view.frame.origin = CGPoint(x: 0.48, y: 0.44) 
self.view.layer.transform = CATransform3DMakeScale(0.94, 0.94, 1) 
self.view.alpha = 0 




UIView.animateWithDuration(0.05, 
      animations: {() -> Void in 
        self.view.layer.transform = CGAffineTransformIdentity 
        self.view.alpha = 1.0 
        self.view.frame.origin = CGPoint(x: 0.01, y: 1.2) 
        self.view.layoutIfNeeded() 
      }) 
+0

謝謝David Yang Liu。你能解釋爲什麼我們需要 - self.view.layer.transform = CGAffineTransformIdentity – user1452936

+0

你的起始轉換是CATransform3DMakeScale(0.94,0.94,1)你想動畫到CATransform3DMakeScale(1,1,1),它基本上是CGAffineTransformIdentity它們分層對其進行任何轉換 –

+0

好的。只有很小的變化。這一行 - self.view.frame.origin = CGPoint(x:0,y:0),x和y會是0.01和1.2? – user1452936