【发布时间】:2019-11-29 16:15:00
【问题描述】:
在我的View Controller 中,我有一个包含 3 个单元格和水平滚动的 collectionView ..
在每个单元格中我都有一个TableView
我在view controller中更改导航栏颜色的动画有问题。
为了管理 - (void) scrollViewDidScroll: (UIScrollView *) scrollView 方法,我创建了一个委托来管理导航栏的颜色变化..
我的问题是我无法将导航栏的 alpha 颜色用作参考 scrollView.contentOffset.y ... 颜色会立即更改,但不会根据 scrollView 的 contentOffset 进行动画处理。
谁能帮我找出我错在哪里?
CollectionView 单元格内的 TableView
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
[self.delegate cellScrollDownWithOffset:scrollView.contentOffset.y];
}
带有collectionView的视图控制器收到委托
#pragma mark - BaseVerticalCell delegate
-(void)cellScrollDownWithOffset:(CGFloat)offset {
[UIView animateWithDuration:.3 animations:^{
UIColor *opacheColor = [UIColor colorWithHexString:@"#F9F9FA" setAlpha:offset /150];
UIColor *defaultColor = [UIColor colorWithWhite:1 alpha:offset /150];
self.navigationController.navigationBar.barTintColor = offset/ 150 > 0 ? opacheColor : defaultColor;
}];
}
【问题讨论】:
标签: ios objective-c uitableview uicollectionview uiscrollview