升级 iOS18后, TabbarController 切换会带有一个缩放动画,下面是自定义取消动画的代码
objectivec
#import "TabBarVC.h"
@interface TabBarVC () <UIViewControllerAnimatedTransitioning, UITabBarControllerDelegate>
@end
@implementation TabBarVC
- (void)viewDidLoad {
[super viewDidLoad];
self.delegate = self;
}
#pragma mark - UITabBarControllerDelegate
- (nullable id <UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController
animationControllerForTransitionFromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC {
return self;
}
#pragma mark - UIViewControllerAnimatedTransitioning
- (void)animateTransition:(nonnull id<UIViewControllerContextTransitioning>)transitionContext {
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
[transitionContext.containerView addSubview:toView];
[transitionContext completeTransition:YES];
}
- (NSTimeInterval)transitionDuration:(nullable id<UIViewControllerContextTransitioning>)transitionContext {
return 0;
}
@end