after a long search with no results, maybe someone knows an answer to the following problem:
I have a UIView which contains a UIWebView as a subview. The UIView is just a wrapper, so that I can place buttons, etc. on top of the UIWebView. I now want to animate the resizing and repositioning of the UIView AND the UIWebView simultaniously. I want it to look like it was just a UIWebView being resized. I tried various animation techniques: block/commit, implicit/explicit, for example like this:
[UIView beginAnimations:@"zoomIn" context:nil];
[UIView setAnimationDuration:1.0];
myWrapperUIView.frame = CGRect(0.0, 0.0, 500.0, 500.0);
myUIWebView.frame = CGRect(0.0, 0.0, 500.0, 500.0);
[UIView commitAnimations];
but I always get the result that the UIView animates kind of right, but the UIWebView inside just instantly switches to the new frame, so if I zoom from a bigger frame there is empty space around the UIWebView which shrinks during the animation.
I also tried an embedded animation for the UIWebView, but same result.
My Question is:
Is there a way to animate both Views simultaniously, so that at each point in time the UIWebWill be filling the UIView?
Thank you,
Michael
use CGAffineTransform and scale the view using transform property, it will do the job.
myWrapperUIView.frame = CGRect(0.0, 0.0, 500.0, 500.0);
myUIWebView.frame = CGRect(0.0, 0.0, 500.0, 500.0);
self.window.userInteractionEnabled =NO;
myWrapperUIView.transform = CGAffineTransformMakeScale(0.01, 0.01);
myUIWebView.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:ANIMATIONDURATION animations:^{
myWrapperUIView.transform = CGAffineTransformMakeScale(1.0, 1.0);
myUIWebView.transform = CGAffineTransformMakeScale(1.0, 1.0);
}completion:^(BOOL finished) {
self.window.userInteractionEnabled = YES;
}];
HOPE THIS HELPS,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With