I simply can't get this to work, I would think it was simple, but no luck.
- (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){
}];
}
This is how the documentation recommends you do it, make a container, add/remove the two subviews you want to flip between.
I can't get it to work. It will just display viewA, then viewB, as if the animation part is skipped, but the block is carried out?
If I switch the container in the [UIView transitionWithView:container
with self.view
it flips the entire view (As suspected) but I can not get it to do this with 2 subviews of self.view
.
Is there no way around this?
I am looking to do something like the iPad Photos app, where a picture will flip and scale to full screen.
I really hope someone could help me out here, thank you in advance.