【问题标题】:How to setup a partial curl modal not hiding toolbar?如何设置不隐藏工具栏的部分卷曲模式?
【发布时间】:2012-04-13 22:19:07
【问题描述】:

在 iPhone 上的 Google 地图应用中,在执行带有部分卷曲过渡的模态后,按钮中的工具栏仍然可见。当我在情节提要中使用部分卷曲设置模态序列时,新的视图控制器会将工具栏隐藏在 parant 视图中。

如何像 Google 地图应用一样设置部分卷曲?

【问题讨论】:

    标签: objective-c ios cocoa-touch uiviewcontroller uistoryboard


    【解决方案1】:

    试试这个代码。这将对你有帮助。请不要犹豫,试试这个代码

    您需要导入 QuartzCore.framework。

    locationMapView 是你的MKMapViewcurlView 是你的第二个UIView

    - (IBAction)curlButtonPressed:(id)sender {
    
        if (isCurlStarted == NO) {
            [UIView animateWithDuration:1.0 
                             animations:^{
                                 CATransition *animation = [CATransition animation];
                                 [animation setDelegate:self];
                                 [animation setDuration:0.7];
                                 [animation setTimingFunction:[CAMediaTimingFunction functionWithName:@"default"]];
                                 animation.type = @"pageCurl";
                                 animation.fillMode = kCAFillModeForwards;
                                 animation.endProgress = 0.65;
                                 [animation setRemovedOnCompletion:NO];
                                 [locationMapView.layer addAnimation:animation forKey:@"pageCurlAnimation"];  
                                 [locationMapView addSubview:curlView];
                                 ;}  
             ];            
            isCurlStarted = YES;
        }else{
            [self curlDownPressed:curlDownButton];
        }
    
    }
    
    - (IBAction)curlDownPressed:(id)sender {
        [UIView animateWithDuration:1.0 
                         animations:^{
                             CATransition *animation = [CATransition animation];
                             [animation setDelegate:self];
                             [animation setDuration:0.7];
                             [animation setTimingFunction:[CAMediaTimingFunction functionWithName:@"default"]];
                             animation.type = @"pageUnCurl";
                             animation.fillMode = kCAFillModeForwards;
                             animation.startProgress = 0.35;
                             [animation setRemovedOnCompletion:NO];
                             [locationMapView.layer addAnimation:animation forKey:@"pageUnCurlAnimation"];  
                             [curlView removeFromSuperview];
    
                             ;}  
         ];
        isCurlStarted = NO;
    }
    

    【讨论】:

    • +1 表示停止动画过渡的想法,但苹果可以证明这种方法,因为 pageCurl 是一个私有 API?
    • 当然是的..为什么不呢?我的应用程序已经在 appstore 中了 :-)
    • stackoverflow.com/a/14622113/1083859 此代码将为您提供更多帮助。我已经优化了这段代码并在那里发布。
    【解决方案2】:

    您可能需要为此使用 OpenGL ES。 Core Animation 展示了使用图层的能力,即使在3-D 中也是如此,但所有图层都只是矩形,它们都是这样操作的。您可以围绕轴为 flipping of a layer 设置动画,即使使用 perspective distortion 也是如此,但您想要做的弯曲类型比使用 Core Animation API 管理的更复杂。

    您或许可以将图像分割成一个由微小层组成的网格,并使用 CATransform3D 对每个层进行操作以创建这种弯曲效果,但此时您也可以使用 OpenGL ES 来创建相同的效果。

    【讨论】:

      猜你喜欢
      • 2011-05-28
      • 1970-01-01
      • 1970-01-01
      • 2020-07-08
      • 2019-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多