自定義PUSH POP跳轉動畫

PUSH
SecondViewController *second=[[SecondViewController alloc]initWithNibName:nil bundle:nil];
    UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:second];
    CGRect destFrame = nav.view.frame;
    destFrame.origin.x = nav.view.frame.size.width;
    nav.view.frame = destFrame;
    destFrame.origin.x = 0;
    [self.view addSubview:nav.view];
    [UIView animateWithDuration:0.25
                     animations:^{
                         nav.view.frame = destFrame;
                     }
                     completion:^(BOOL finished) {
                         [self.navigationController presentViewController:nav animated:NO completion:nil];
                     }];

POP

-(void)btnAction:(id)sender
{
    [self.navigationController.view.layer addAnimation:[self getPopAnimation] forKey:nil];
    self.navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
-(CATransition*)getPopAnimation
{
    CATransition *transition = [CATransition animation];
    transition.duration = 0.5f;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromLeft;
    return transition;
}


發佈了53 篇原創文章 · 獲贊 0 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章