单击UI按钮,然后从上到下打开新的UIviewController,如下拉

时间:2015-10-21 11:51:21

标签: ios iphone

(IBAction)btnClick:(id)sender
{
    secondView *sc= [self.storyboard instantiateViewControllerWithIdentifier:@"secondView"];
    [self.navigationController pushViewController:sc animated:YES];
}

2 个答案:

答案 0 :(得分:0)

您应该使用以下代码实现不同的导航风格,希望这对您有所帮助。

UIViewController * secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"secondView"];


CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
//transition.subtype = kCATransitionFromTop; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom

[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:secondView animated:NO];

快乐的编码!

对于视图动画:

对于从下到上的动画,请在下方添加

[UIView animateWithDuration:0.5
                      delay:0.1
                    options: UIViewAnimationCurveEaseIn
                 animations:^{
                     self.postStatusView.frame = CGRectMake(0, 0, 320, 460);
                 } 
                 completion:^(BOOL finished){
                 }];
[self.view addSubview:self.postStatusView];

答案 1 :(得分:0)

尝试像这样

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
DetailViewController *eventDetailsViewController = [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];

eventDetailsViewController.view.frame= CGRectMake(0, -self.view.bounds.size.height, self.view.bounds.size.width, self.view.bounds.size.height);
eventDetailsViewController.view.backgroundColor = [UIColor redColor];

[UIView animateWithDuration:1.5 delay:0.f options:UIViewAnimationOptionCurveEaseInOut animations:^{
    [eventDetailsViewController.view setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
} completion:^(BOOL finished){

}];

[self.view addSubview:eventDetailsViewController.view];
[self addChildViewController:eventDetailsViewController];