【发布时间】:2012-04-13 22:19:07
【问题描述】:
在 iPhone 上的 Google 地图应用中,在执行带有部分卷曲过渡的模态后,按钮中的工具栏仍然可见。当我在情节提要中使用部分卷曲设置模态序列时,新的视图控制器会将工具栏隐藏在 parant 视图中。
如何像 Google 地图应用一样设置部分卷曲?
【问题讨论】:
标签: objective-c ios cocoa-touch uiviewcontroller uistoryboard
在 iPhone 上的 Google 地图应用中,在执行带有部分卷曲过渡的模态后,按钮中的工具栏仍然可见。当我在情节提要中使用部分卷曲设置模态序列时,新的视图控制器会将工具栏隐藏在 parant 视图中。
如何像 Google 地图应用一样设置部分卷曲?
【问题讨论】:
标签: objective-c ios cocoa-touch uiviewcontroller uistoryboard
试试这个代码。这将对你有帮助。请不要犹豫,试试这个代码。
您需要导入 QuartzCore.framework。
locationMapView 是你的MKMapView,curlView 是你的第二个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;
}
【讨论】:
您可能需要为此使用 OpenGL ES。 Core Animation 展示了使用图层的能力,即使在3-D 中也是如此,但所有图层都只是矩形,它们都是这样操作的。您可以围绕轴为 flipping of a layer 设置动画,即使使用 perspective distortion 也是如此,但您想要做的弯曲类型比使用 Core Animation API 管理的更复杂。
您或许可以将图像分割成一个由微小层组成的网格,并使用 CATransform3D 对每个层进行操作以创建这种弯曲效果,但此时您也可以使用 OpenGL ES 来创建相同的效果。
【讨论】: