user1452936
user1452936

Reputation: 575

animation on alert box

I have a alert box and would like to apply below animation when it "appears":

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

Can someone guide on how to achieve this in swift ?

Code:

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

Thanks.

Upvotes: 0

Views: 284

Answers (1)

David Yang Liu
David Yang Liu

Reputation: 1170

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()
            })

Upvotes: 1

Related Questions