addSubview到视图 - 显示为PageCurlDown

时间:2012-02-08 09:58:03

标签: iphone ios animation core-animation

我在视图控制器中向self.view添加一个视图(比如说redView)。

现在问题是我想要在添加redView时向下卷曲动画。

有可能得到它吗?

2 个答案:

答案 0 :(得分:1)

萨姆帕斯,

我是在我正在开发的应用中执行此操作。

这就是我所做的,它运作良好:

[self.view insertSubview:redView atIndex:0]

[UIView transitionWithView:self.view 
                  duration:1.0 
                   options:UIViewAnimationOptionTransitionCurlDown 
                animations:^{ [[[self.view subviews] objectAtIndex:1] removeFromSuperview];} 
                completion:NULL];

希望它适合你。

基思

答案 1 :(得分:1)

如果redView是UIViewController的subClass。

第一种方法

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
                       forView:redView.view
                         cache:YES];

[self.view addSubview:redView.view];
[UIView commitAnimations];

第二种方法

RedView *viewController = [[RedView alloc] initWithNibName:@"RedView" bundle:nil];
    [viewController setModalTransitionStyle:UIModalTransitionStylePartialCurl];
    [self presentModalViewController:viewController animated:YES];

如果redView是UIView的subClass。

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
                       forView:redView
                         cache:YES];

[self.view addSubview:redView];
[UIView commitAnimations];