fix: 消除 TabBar 切换时的页面闪烁问题

核心修复:
1. 移除导航栏动画冲突
   - 移除 viewWillAppear 中的 navigationBar 隐藏逻辑
   - ViewController 未包装在 NavigationController 中,调用导航栏方法会触发冗余动画

2. 禁用 UITabBarController 默认切换动画
   - 设置 UITabBarControllerDelegate
   - animationControllerForTransitionFrom 返回 nil 禁用系统动画
   - 使用 UIView.performWithoutAnimation 确保无动画切换

3. 修复背景色未定义导致的白色闪烁
   - 显式设置浅灰色背景作为兜底 (RGB: 0.95, 0.95, 0.97)
   - 添加背景图片的 contentMode 和 clipsToBounds 属性
   - 确保背景图片加载延迟时不显示白色

修复后效果:
- Tab 切换流畅无闪烁,仅保留按钮缩放动画
- 背景色始终一致,无白色背景闪现
- 性能提升,消除多个动画冲突
This commit is contained in:
edwinQQQ
2025-10-10 15:58:23 +08:00
parent 49ac7efa66
commit 8b177e5fad
3 changed files with 60 additions and 37 deletions

View File

@@ -63,8 +63,8 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//
[self refreshUserInfo];
// ViewController NavigationController
// TabBarController UINavigationController
}
// MARK: - Setup
@@ -82,8 +82,12 @@
}
- (void)setupUI {
//
self.view.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.97 alpha:1.0];
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:kImage(@"vc_bg")];
bgImageView.contentMode = UIViewContentModeScaleAspectFill;
bgImageView.clipsToBounds = YES;
[self.view addSubview:bgImageView];
[bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
@@ -201,6 +205,9 @@
- (void)refreshData {
self.currentPage = 1;
[self.momentsData removeAllObjects];
//
[self loadUserInfo];
[self loadUserMoments];
}