如何在iOS 7上像iPad appstore一样进行视图转换

时间:2014-03-09 18:01:49

标签: ios objective-c ipad uiviewanimationtransition

我想进行视图转换,例如iOS 7上的iPad AppStore,点击一个项目(应用程序)并弹出一个垂直翻转的详细视图,并且点击详细视图外部将忽略,此视图转换既不像popover也不是模态转变。 那么,我该如何进行这种转变...

感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

开始here。这是一个例子:

[UIView transitionWithView:newView
                  duration:1
                   options:UIViewAnimationOptionTransitionFlipFromLeft 
                animations:^{         // put the animation block here
                           }
                completion:NULL];

答案 1 :(得分:0)

还在寻找过渡动画。但我确实弄明白了如何在窗外进行攻击以解除/关闭。它可以找到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];
        }
    }
}

希望这有帮助!