gpt4 book ai didi

ios - 如何在 iOS 7 上像 iPad appstore 一样进行 View 转换

转载 作者:行者123 更新时间:2023-12-01 16:43:20 25 4
gpt4 key购买 nike

我想进行 View 转换,例如 iOS 7 上的 iPad AppStore,单击一个项目(应用程序)并弹出一个垂直翻转的详细 View ,然后在详细 View 之外点击将关闭,这种 View 转换既不像弹出框和模态转换。
那么,我该如何进行这种过渡...

感谢您的帮助。

最佳答案

也在寻找过渡动画。但我确实想出了如何在窗口外完成点击以关闭/关闭。可以找到here .

在您的 viewDidAppear您创建一个 UITapGestureRecognizer 并将其添加到 View 的窗口。像这样:

UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapBehind:)];
[recognizer setNumberOfTapsRequired:1];
recognizer.cancelsTouchesInView = NO;
[self.view.window addGestureRecognizer:recognizer];
handleTapBehind检查手势的状态是否已经结束并获取点击的位置并关闭 View /窗口
- (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];
}
}
}

希望这可以帮助!

关于ios - 如何在 iOS 7 上像 iPad appstore 一样进行 View 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22285884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com