Reputation: 575
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
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