【问题标题】:iPhone View AnimationiPhone 查看动画
【发布时间】:2011-10-09 00:30:13
【问题描述】:

我正在尝试切换视图,但我希望动画与视图抬起并像折叠一张纸以查看下面的内容。

如果是动画,任何有关如何获取该视图动画的教程或示例都将不胜感激。

实际上是当您点击角落的按钮时地图应用使用的视图。

【问题讨论】:

    标签: iphone objective-c ios4 iphone-sdk-3.0


    【解决方案1】:

    这样的事情应该可以工作:

    MyViewController *myView = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
    myView.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissModalViewControllerAnimated:)] autorelease];
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:myView];
    navigation.modalTransitionStyle = UIModalTransitionStylePartialCurl;
    navigation.delegate = self;
    [self presentModalViewController:navigation animated:YES];
    

    这里的关键是modalTransitionStyle属性需要设置为UIModalTransitionStylePartialCurl,然后才能呈现模态视图。

    更多信息在这里:UIViewController Class Reference(寻找modalPresentationStylemodalTransitionStylepresentModalViewController:animated:dismissModalViewControllerAnimated:)。

    【讨论】:

      【解决方案2】:

      有两种基本方法,旧的不再推荐:

      [UIView beginAnimations:nil context:nil];
      [UIView setAnimationDuration:0.5];
      [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown 
                                        forView:containerView cache:YES];
      
      [containerView addSubview:subview];
      
      [UIView commitAnimations];
      

      还有新的(它使用 iOS 4 及更高版本支持的块):

      [UIView transitionWithView:containerView duration:0.5
          options:UIViewAnimationOptionTransitionCurlDown
          animations:^ { [containerView addSubview:subview]; }
          completion:nil];
      

      【讨论】:

      • 虽然理论上可以回答这个问题,it would be preferable 在这里包含答案的基本部分,并提供链接以供参考。
      • “转到此页面(该页面可以更改,或完全消失,只要有第三方喜欢它)”不是答案。在这里总结/解释。
      猜你喜欢
      • 1970-01-01
      • 2011-06-28
      • 2012-08-19
      • 2023-03-10
      • 1970-01-01
      • 2018-06-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多