I can't find the answer here anyway, nor do I see a duplicate question.
My code is simple. Given 3 UIView, parent, from and to, remove from from parent and add subview. + add animation but that's just doodads.
Now, the problem is when I do that, the to then get offsetted. It's as if it's pushed down.
I even add To.frame=ParentView.frame; to make sure it works. It doesn't.
What should I have done?
+ (void) AnimateSwitchingWithParent: (UIView *) ParentView From: (UIView *) From To: (UIView* ) To
/*[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:ParentView cache:YES];*/
To.frame=ParentView.frame; //If I don't do this, the subview is still off by around 20 points
NSLog(@"To.bounds: %@", NSStringFromCGRect(To.bounds));
NSLog(@"From.bounds.: %@", NSStringFromCGRect(From.bounds));
NSLog(@"ParentView.bounds: %@", NSStringFromCGRect(ParentView.bounds));
Seems you misunderstand the frame and bounds, revise your code to
To.frame=ParentView.bounds; should be OK.