gpt4 book ai didi

ios - UIView 动画翻转不工作

转载 作者:行者123 更新时间:2023-11-28 22:39:11 24 4
gpt4 key购买 nike

在 UIView 子类中我有这个:

self.frontImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"front"]];
self.backImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"back"]];
[self addSubview:self.backImageView];


[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
[self.backImageView removeFromSuperview];
[self addSubview:self.frontImageView];}

completion:^(BOOL finished){
//nothing
}];

但我没有得到翻转动画。正面 ImageView 立即出现。我做错了什么?

最佳答案

你在使用

时犯了一个愚蠢的错误
animateWithDuration:delay:options:animations:completion:

代替

transitionFromView:toView:duration:options:completion:

您的代码应该是:

[UIView transitionFromView:backImageView
toView:frontImageView
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:^(BOOL finished) {
// animation completed
}];

关于ios - UIView 动画翻转不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15031793/

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