D_D*_*D_D 15 iphone core-animation core-graphics ios
如何在iOS中添加子视图时提供反弹或弹出式动画?我需要类似于UIAlertView外观风格的东西.我知道有几种方法可以做同样的事情:但我更喜欢在[UIView animateWithDuration: ...];这里使用基本块,所以我可以得到一些关于transform我应该在这里使用以获得弹出效果的帮助吗?
谢谢
Par*_*iya 48
Animation 对于PopUp风格:
yourView.transform = CGAffineTransform(scaleX: 0.01, y: 0.01)
UIView.animate(withDuration: 0.2, delay: 0, options: .curveEaseOut, animations: {() -> Void in
yourView.transform = .identity
}, completion: {(finished: Bool) -> Void in
// do something once the animation finishes, put it here
})
Run Code Online (Sandbox Code Playgroud)
Reverse Animation与hiding该same View
yourView.transform = .identity
UIView.animate(withDuration: 0.2, delay: 0, options: .curveEaseOut, animations: {() -> Void in
yourView.transform = CGAffineTransform(scaleX: 0.01, y: 0.01)
}, completion: {(finished: Bool) -> Void in
// do something once the animation finishes, put it here
yourView.isHidden = true
})
Run Code Online (Sandbox Code Playgroud)
yourView.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
yourView.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished){
// do something once the animation finishes, put it here
}];
Run Code Online (Sandbox Code Playgroud)
Reverse Animation与hiding该same View
yourView.transform = CGAffineTransformIdentity;
[UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
yourView.transform = CGAffineTransformMakeScale(0.01, 0.01);
} completion:^(BOOL finished){
yourView.hidden = YES;
}];
Run Code Online (Sandbox Code Playgroud)