gpt4 book ai didi

ios - Quartz 2D 的仿射变换序列

转载 作者:可可西里 更新时间:2023-11-01 05:15:36 24 4
gpt4 key购买 nike

我正在尝试使用 iOS 中的 UIAlertView 在 OS X 中模拟不正确的密码输入动画。本质上我希望它向左翻译警报然后向右翻译。这是我正在做的:

    [UIView animateWithDuration:0.5 
animations:^{
alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 200, 0);
alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, -200, 0);
}];

但这并没有达到预期的效果。警报瞬间向右射出,然后平滑地向左移动。我怎样才能让这两个翻译在彼此之后顺利发生?

最佳答案

试试这个:

[UIView animateWithDuration:0.5 animations:^{

alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 200, 0);

} completion:^(BOOL finished) {

[UIView animateWithDuration:0.5 animations:^{
alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, -200, 0);
}];
}];

但我会像这样制作动画:

[UIView animateWithDuration:0.1 animations:^{

alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 20, 0);

} completion:^(BOOL finished) {

[UIView animateWithDuration:0.1 animations:^{

alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, -20, 0);

} completion:^(BOOL finished) {

[UIView animateWithDuration:0.1 animations:^{
alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 0, 0);
}];

}];
}];

由你决定! ;-)

关于ios - Quartz 2D 的仿射变换序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8625844/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com