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:
@@ -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];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user