【问题标题】:Distorting UITableViewCell when scrolling?滚动时扭曲 UITableViewCell?
【发布时间】:2014-05-10 02:11:16
【问题描述】:

当用户滚动UITableView 时,我尝试在 iOS 应用中制作一些特殊效果。我想实现的效果是:

来自here

它是由 Capptivate 制作的,但我浏览了网站,但我仍然很困惑在哪里可以获得该库。

我知道 Core Graphics / Core Animation / QuartzCore Framework 可能会有所帮助,正如tutorial 所暗示的那样。那么,假设效果是基于UITableView,我怎样才能像上面的截图那样扭曲UITableViewCell

我可以通过以下方式制作弯曲的表格单元格:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * CellIdentifier = @"Cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (![cell.backgroundView isKindOfClass:[CustomCellBackground class]]) {
        CustomCellBackground * backgroundCell = [[CustomCellBackground alloc] init];
        cell.backgroundView = backgroundCell;
    }

    if (![cell.selectedBackgroundView isKindOfClass:[CustomCellBackground class]]) {
        CustomCellBackground * selectedBackgroundCell = [[CustomCellBackground alloc] init];
        selectedBackgroundCell.selected = YES;
        cell.selectedBackgroundView = selectedBackgroundCell;
    }

    NSString * entry;

    if (indexPath.section == 0) {
        entry = self.thingsToLearn[indexPath.row];
        ((CustomCellBackground *) cell.backgroundView).lastCell = indexPath.row == self.thingsToLearn.count - 1;
        ((CustomCellBackground *)cell.selectedBackgroundView).lastCell = indexPath.row == self.thingsToLearn.count - 1;
    } else {
        entry = self.thingsLearned[indexPath.row];
        ((CustomCellBackground *)cell.backgroundView).lastCell = indexPath.row == self.thingsLearned.count - 1;
        ((CustomCellBackground *)cell.selectedBackgroundView).lastCell = indexPath.row == self.thingsLearned.count - 1;
    }

    cell.textLabel.text = entry;
    cell.textLabel.backgroundColor = [UIColor clearColor];
    cell.textLabel.highlightedTextColor = [UIColor blackColor];

    return cell;
}

但我不知道如何让它响应滚动。

我的问题是:简而言之,滚动时如何使UITableViewCell 弯曲?


我阅读了更多 SO 问题:

还有一些教程:

注意:我只在 iOS 7+ 上工作。

【问题讨论】:

  • 如果您在具有固定数量元素的表格中工作(例如菜单),那么我会使用子视图,然后使用 Quartz 创建由 touchesMoved 方法控制的贝塞尔曲线的路径,而不是使用 UITableView 和 UITableViewCells。请记住,最终您在应用中看到的几乎都是 UIView 或其子类.....e
  • 另外,请查看我发布的在 touchesMoved 中操纵贝塞尔曲线的示例,这可能会对您有所帮助。 stackoverflow.com/questions/22720179/…

标签: ios uitableview core-graphics core-animation


【解决方案1】:

请看看这个 github 库 - https://github.com/brocoo/BRFlabbyTable

【讨论】:

    猜你喜欢
    • 2014-11-05
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多