我正在实现一个非常简单的翻转动画,但没有翻转。
我使用文档中的示例作为模板,Apple 现在建议您使用动画块,这是采用的方法:(来自文档)
[UIView transitionWithView:containerView
duration:0.2
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{ [fromView removeFromSuperview]; [containerView addSubview:toView]; }
completion:NULL];
将要在容器中转换的两个视图包装起来。我这样做。
UIView *container = [[UIView alloc] initWithFrame:target];
[self.view addSubview:container];
[container addSubview:productImage];
UIView *background = [[UIView alloc] initWithFrame:target];
[background setBackgroundColor:[UIColor darkGrayColor]];
[background setAlpha:0.1f];
[UIView transitionWithView:container
duration:0.8
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
[[[container subviews] objectAtIndex:0] removeFromSuperview];
[container addSubview:background];
}
completion:NULL];
发生了两件奇怪的事情:没有过渡,容器显示 productImage(UIImageView 类型),然后将其与背景视图交换。没有动画。
第二件事是让我相信这不是常见的错字,是
UIViewAnimationOptionTransitionFlipFromRight
Xcode 无法识别,它不会自动完成,也不会突出显示。只有当我使用已弃用的 Xcode 时,Xcode 才会这样做:
UIViewAnimationTransitionFlipFromRight //i.e. without the Option part
然后我开始检查我的 SDK 版本等。一切似乎都设置为 4.2,XCode 是 3.2.5 版本,目标和项目设置都将构建和部署目标设置为 4.2。
我在这里想念什么?
希望一组训练有素的眼睛可以帮助我:)提前谢谢你。