我正在开发一款iPad应用程序。我有一个视图控制器,我想要在弹出控制器中显示它。但我也想添加自定义动画到弹出时,在modalview中呈现它。如何在显示和关闭模式视图的同时向弹出窗口添加自定义动画?
下面是我的代码:
Myviewcontroller *myViewController = [[Myviewcontroller alloc] initWithNibName:@"Myviewcontroller" bundle:nil];
UINavigationController *navController=[[UINavigationController alloc] initWithRootViewController:myViewController];
myViewController.contentSizeForViewInPopover=CGSizeMake(900, 600);
UIPopoverViewController popOVer = [[UIPopoverController alloc]
initWithContentViewController:navController];
[popover presentPopoverFromRect:CGRectMake(37, 90, 950, 560) inView:self.view permittedArrowDirections:0 animated:NO];我想添加到上面的popoverViewController中的动画是:
CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat:(2 * M_PI) * 3]; // 3 is the number of 360 degree rotations
rotationAnimation.duration = 1.0f;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation.fromValue = [NSNumber numberWithFloat:0.0];
scaleAnimation.toValue = [NSNumber numberWithFloat:1.0];
scaleAnimation.duration = 1.0f;
scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.duration = 1.0f;
[animationGroup setAnimations:[NSArray arrayWithObjects:rotationAnimation, scaleAnimation, nil]];现在我的问题是如何将此动画添加到popOverViewController本身。因为Popover没有任何view属性,所以我不能给它添加任何动画。如果我在弹出窗口内的视图控制器中添加动画,那么弹出窗口会停留在它的位置,而它里面的视图会产生动画效果,这看起来并不好。
发布于 2011-07-19 21:52:36
无法执行此操作,弹出窗口不是视图控制器。
https://stackoverflow.com/questions/6747547
复制相似问题