NSArray *subViews = [self subviews];
NSUInteger index = 0;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
// cache:YES if you want to comeback from up to down or down to up
[UIView setAnimationTransition:transition forView:self cache:NO];
if ([oldView superview] == self) {
// Find the index of oldView so that we can insert newView at the same place
for(index = 0; [subViews objectAtIndex:index] != oldView; ++index) {}
[oldView removeFromSuperview];
}
// If there's a new view and it doesn't already have a superview, insert it where the old view was
if (newView && ([newView superview] == nil))
[self insertSubview:newView atIndex:index];
{
NSArray *subViews = [self subviews];
NSUInteger index = 0;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
// cache:YES if you want to comeback from up to down or down to up
[UIView setAnimationTransition:transition forView:self cache:NO];
if ([oldView superview] == self) {
// Find the index of oldView so that we can insert newView at the same place
for(index = 0; [subViews objectAtIndex:index] != oldView; ++index) {}
[oldView removeFromSuperview];
}
// If there's a new view and it doesn't already have a superview, insert it where the old view was
if (newView && ([newView superview] == nil))
[self insertSubview:newView atIndex:index];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
[self replaceCurlSubview:oldView withSubView:newView transition:UIViewAnimationTransitionCurlUp duration:0.5];