有時候頁面跳轉或視圖切換的時候,須要作成特定的效果,常見的push、pop、present、dismiss效果以下,注意要添加
CATransition *transition = [CATransition animation]; transition.duration = 0.3f; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = kCATransitionPush; transition.subtype = kCATransitionFromRight; transition.delegate = self; [self.contentView.layer addAnimation:transition forKey:nil]; [self.contentView addSubview:self.productDetailController.view];
CATransition *transition = [CATransition animation]; transition.duration = 0.3f; transition.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = kCATransitionPush; transition.subtype = kCATransitionFromLeft; transition.delegate = self; [self.view.superview.layer addAnimation:transition forKey:nil]; [self.view removeFromSuperview];
CATransition *transition = [CATransition animation]; transition.duration = 0.4f; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = kCATransitionMoveIn; transition.subtype = kCATransitionFromTop; transition.delegate = self; [[self currentNavigationController].view.layer addAnimation:transition forKey:nil]; [[self currentNavigationController] pushViewController:playVC animated:NO];
CATransition *transition = [CATransition animation]; transition.duration = 0.3f; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = kCATransitionReveal; transition.subtype = kCATransitionFromBottom; transition.delegate = self; [self.navigationController.view.layer addAnimation:transition forKey:nil]; [self.navigationController popViewControllerAnimated:NO];