【发布时间】:2014-05-29 01:02:27
【问题描述】:
我想进行视图转换,例如 iOS 7 上的 iPad AppStore,单击一个项目(应用程序)并弹出一个带有垂直翻转的详细视图,然后在详细视图之外点击将关闭,此视图转换既不像 popover 和模态过渡。 那么,我该如何进行这种过渡...
感谢您的帮助。
【问题讨论】:
标签: ios objective-c ipad uiviewanimationtransition
我想进行视图转换,例如 iOS 7 上的 iPad AppStore,单击一个项目(应用程序)并弹出一个带有垂直翻转的详细视图,然后在详细视图之外点击将关闭,此视图转换既不像 popover 和模态过渡。 那么,我该如何进行这种过渡...
感谢您的帮助。
【问题讨论】:
标签: ios objective-c ipad uiviewanimationtransition
也在寻找过渡动画。但我确实想出了如何在窗口外完成点击以关闭/关闭。可以找到here。
在您的viewDidAppear 中,您创建一个 UITapGestureRecognizer 并将其添加到视图的窗口中。像这样:
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapBehind:)];
[recognizer setNumberOfTapsRequired:1];
recognizer.cancelsTouchesInView = NO;
[self.view.window addGestureRecognizer:recognizer];
handleTapBehind 检查手势状态是否已结束并获取点击的位置并关闭视图/窗口
- (void)handleTapBehind:(UITapGestureRecognizer *)sender{
if (sender.state == UIGestureRecognizerStateEnded){
CGPoint location = [sender locationInView:nil]; //Passing nil gives us coordinates in the window
//Check to see if it's in or outside. If outside, dismiss the view.
if (![self.view pointInside:[self.view convertPoint:location fromView:self.view.window] withEvent:nil]){
// Remove the recognizer first so it's view.window is valid.
[self.view.window removeGestureRecognizer:sender];
[self dismissViewControllerAnimated:YES completion:nil];
}
}
}
希望这会有所帮助!
【讨论】:
开始here。这是一个例子:
[UIView transitionWithView:newView
duration:1
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{ // put the animation block here
}
completion:NULL];
【讨论】: