我根本无法让它工作,我认为这很简单,但没有运气。
- (void) animate {
UIView *viewA = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 300.0f, 100.0f)];
[viewA setBackgroundColor:[UIColor blueColor]];
UIView *viewB = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 300.0f, 100.0f)];
[viewB setBackgroundColor:[UIColor brownColor]];
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(10.0f, 10.0f, 300.0f, 100.0f)];
[container addSubview:viewA];
[self.view addSubview:container];
[UIView transitionWithView:container
duration:0.4
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
[[[container subviews] objectAtIndex:0] removeFromSuperview];
[container addSubview:viewB];
}
completion:^(BOOL finished){
}];
}
这就是文档建议您这样做的方式,制作一个容器,添加/删除您想要在其之间翻转的两个子视图。
我无法让它工作。它只会显示viewA,然后是viewB,好像动画部分被跳过了,但是块被执行了?
如果我在其中切换容器,[UIView transitionWithView:container
它self.view
会翻转整个视图(正如怀疑的那样),但我无法使用self.view
.
有没有办法解决这个问题?
我正在寻找类似 iPad Photos应用程序的东西,其中图片将翻转并缩放到全屏。
我真的希望有人可以在这里帮助我,提前谢谢你。