2012-12-26 45 views
0

任何人都知道如何实现像viewController没有全屏,就像当我们在iPhone中搜索时点击? 我希望当用户向上滑动viewController(半高)显示。 没有segue!我希望同时显示旧的视图控制器。 在此先感谢viewController没有全屏

回答

1

我添加这种类型的对整个项目的功能,我添加了QRView的窗口,使用户SWIP了从项目的任何观点认为...

见我的代码示例..

刚刚成立在UISwipeGestureRecognizer你的第二个观点要提出像波纹管......

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]; 

,这时候你向上轻扫观点称为波纹管的方法...

而且只需添加一个BOOL变量名称为isViewPop个它在你的viewDidLoad:方法设置为NO ..

-(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]; 
} 

我希望这个答案对你有帮助...

+1

非常感谢Paras Joshi! –

0

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

1

如果它是简单的,我会添加一个UIView到您的UIViewController的底部 - 然后当您点击“搜索“也好,动画效果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); 
+0

完美非常感谢RyanG! –