ios - 需要随着底部列表滚动移动顶部的红色选择器
问题描述
我需要将上面显示的红色选择器与底部的水平滚动视图一起移动。目前它是在滚动完成后发生的。
这是我正在使用的代码:
- (void)scrollViewDidEndDecelerating1:(UIScrollView *)scrollView {
if (scrollView.contentOffset.x == 0) {
[UIView animateWithDuration:0.25 animations:^{
self.selectMessageCatagoriesLabel.frame = CGRectMake(0, 41, [CommonUtils getFlexibleWidth:125], 3);
} completion:^(BOOL finished) {
}];
}
else if (scrollView.contentOffset.x == 375) {
[UIView animateWithDuration:0.25 animations:^{
self.selectMessageCatagoriesLabel.frame = CGRectMake([CommonUtils getFlexibleWidth:125], 41, [CommonUtils getFlexibleWidth:125], 3);
} completion:^(BOOL finished) {
}];
}
else{
[UIView animateWithDuration:0.25 animations:^{
self.selectMessageCatagoriesLabel.frame = CGRectMake([CommonUtils getFlexibleWidth:250], 41, [CommonUtils getFlexibleWidth:125], 3);
} completion:^(BOOL finished) {
}];
}
}
请检查屏幕截图以供参考
解决方案
您可以使用scrollViewDidScroll
方法 from UIScrollViewDelegate
,因此您可以在此方法中移动您的代码。您不需要在此方法中使用动画,因为它调用非常频繁。
推荐阅读
- python - 检查python中远程Windows机器上是否存在文件
- angular - @import '~@material/theme'; 在styles.css 中不起作用
- android - Google 助理无法在 Activity 中启动
- jsonschema - 如何对集合 + json 对象进行 json 模式验证?
- xml - 在 xslt 1.0 上使用动态 xpath 的值
- apache-kafka - KafkaConsumer#poll 对于 Kafka 客户端版本 0.8.2 始终返回 null
- opendaylight - 杨:如何将 yang 模式转换为 XML
- python - 在python3中将一个函数包裹在另一个函数上
- java - eclipse Ant Build 包不存在
- algorithm - 对二维矩阵进行分区