0

任何人都知道如何实现类似 viewController 的东西,就像我们在 iPhone 中点击搜索时一样,没有全屏?我希望当用户向上滑动时显示 viewController(半高)。没有转场!!我希望同时显示旧的视图控制器。提前致谢

4

3 回答 3

1

I Add this type of functionality for whole project, i add the QRView in window so user swip up the view from any view of project...

See the Example of my code..

Just set the UISwipeGestureRecognizer to your second view which you want to present like bellow...

 CATransition *animation = [CATransition animation];
    [animation setDelegate:self];   
    [animation setType:kCATransitionFade];
    [animation setDuration:0.5];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                                  kCAMediaTimingFunctionEaseInEaseOut]];
    [[self.view layer] addAnimation:animation forKey:kAnimationKey];
    UISwipeGestureRecognizer *swipeGesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(addCustomBottomBar)] autorelease];
    swipeGesture.numberOfTouchesRequired = 1;
    swipeGesture.direction = (UISwipeGestureRecognizerDirectionDown);
    [yourViewController.view addGestureRecognizer:swipeGesture];/// use your view name here, its depends on your requirement
    UISwipeGestureRecognizer *swipeGestureTop = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(addCustomBottomBar)] autorelease];
    swipeGestureTop.numberOfTouchesRequired = 1;
    swipeGestureTop.direction = (UISwipeGestureRecognizerDirectionUp);

    [yourViewController.view addGestureRecognizer:swipeGestureTop];

and this bellow method called when you swipe up view...

Also just add one BOOL variable with name isViewPop and set it to NO in your viewDidLoad: method ..

-(void)addCustomBottomBar{

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.window cache:YES];

    if (isqrcodepop) {
        isViewPop=NO;

        yourViewController.view.frame=CGRectMake(0, 430, 320, 70);
    }
    else{
        isViewPop=YES;

        yourViewController.view.frame=CGRectMake(0, 210, 320, 270);
        [self.view bringSubviewToFront:yourViewController.view];
    }
    [UIView commitAnimations];
}

i hope this answer helpful for you...

于 2012-12-27T05:23:05.183 回答
1

如果它很简单,我会在UIViewUIViewController的底部下方添加一个 - 然后当您点击“搜索”或其他任何内容时,UIView使用动画块将其动画化:

- (IBAction)btnTouch:(id)sender
{
        [UIView animateWithDuration:0.3
                              delay:0.0
                            options: UIViewAnimationCurveEaseInOut
                         animations:^{

                              //bring searchView up
                             _searchView.transform = CGAffineTransformMakeTranslation(0, -80);

                         }
                         completion:^(BOOL finished){

                         }

         ];
}

然后当你完成后,通过使用与此行相同的动画块将视图推回其原点:

_searchView.transform = CGAffineTransformMakeTranslation(0, 0);
于 2012-12-26T23:58:15.460 回答
0

您可以拥有背景视图控制器[self presentViewController:vc animated:YES completion:nil];并将前视图控制器的框架设置为屏幕的一半。这样,由于前视图的下半部分是透明的,因此您的背景视图控制器仍然可见

于 2012-12-26T23:49:03.527 回答