【问题标题】:Keep the first visable headerview’s uilabel’s textcolor = yellow when sliding the uicollectionview滑动 uicollectionview 时保持第一个可见 header view 的 uilabel 的 text color = yellow
【发布时间】:2018-10-28 12:50:26
【问题描述】:

我想让uicollectionview的第一个visable headerview的uilabel的颜色为黄色,滑动uicollectionview时另一个visable headerview为黑色。

我怎样才能做到这一点?

【问题讨论】:

    标签: ios objective-c uicollectionview


    【解决方案1】:

    问题已经完美解决,下面我上传了demo:

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
        if (scrollView == self.CollectionView) {
    //Calculate the section with contentOffset
            CGFloat contentOffset = scrollView.contentOffset.y;
            NSInteger lastSection = self.firstSection;
            if (contentOffset <= 0) {
                self.firstSection = 0;
            } else {
                for (NSInteger section = 0; section < self.playListArr.count - 1; section++) {
                    contentOffset = contentOffset - (HEADER_VIEW_HEIGHT + (LINE_SPACING + CELL_HEIGHT) * ceil([(NSMutableArray *)self.playListArr[section] count] / 3.0) - LINE_SPACING);
                    if (contentOffset <= 0 || section == self.playListArr.count - 1) {
    //return the current first section:
                        self.firstSection = section;
                        break;
                    }
                }
            }
    }
    

    【讨论】:

      猜你喜欢
      • 2015-07-31
      • 1970-01-01
      • 2014-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-25
      • 2021-06-26
      相关资源
      最近更新 更多