我不理解 UIViewTransitionfromView 的奇怪行为而发疯:第二个视图首先显示,没有动画。这是代码:
UIImageView *backstar=[[UIImageView alloc]initWithFrame:CGRectMake(50, 50, 205, 205)];
backstar.image=[UIImage imageNamed:@"backstar.png"];
UIImageView *star=[[UIImageView alloc]initWithFrame:CGRectMake(50, 50, 205, 205)];
star.image=[UIImage imageNamed:@"star.png"];
UIView *containerView=[[UIView alloc]initWithFrame:CGRectMake(50, 50, 205, 205)];
containerView.backgroundColor=[UIColor blackColor];
[self.view addSubview:containerView];
[containerView addSubview:backstar]; // if I don't do this nothing happens, container view stays f*** deep black
[containerView addSubview:star];
//if i remove the animation line, star is displayed of course, on top of backstar
[UIView transitionFromView:star toView:backstar duration:2.0 options:UIViewAnimationOptionShowHideTransitionViews | UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished){} ];
我到底错在哪里?正如Apple doc中所说,应该可以不删除imageViews而是显示/隐藏它们!
非常感谢