【问题标题】:Need to move the top red selector along with the bottom list scrolling需要随着底部列表滚动移动顶部的红色选择器
【发布时间】:2020-02-29 01:00:28
【问题描述】:

我需要将上面显示的红色选择器连同底部的水平滚动视图一起移动。目前它是在滚动完成后发生的。

这是我正在使用的代码:

- (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) {
        }];
    }
}

请查看截图以获取参考

【问题讨论】:

    标签: ios objective-c cocoa-touch uiscrollview uiscrollviewdelegate


    【解决方案1】:

    您可以使用UIScrollViewDelegate 中的scrollViewDidScroll 方法,因此您可以在此方法中移动您的代码。在这个方法中你不需要使用动画,因为它调用非常频繁。

    【讨论】:

      猜你喜欢
      • 2021-06-26
      • 2013-01-25
      • 2012-10-09
      • 2013-01-04
      • 2021-10-18
      • 1970-01-01
      • 1970-01-01
      • 2017-04-13
      • 1970-01-01
      相关资源
      最近更新 更多