I try to make some special effects in an iOS App when user scrolls the UITableView
. The effects I would like to implement is:
which is from here.
It is made by Capptivate, but I read through the website & I'm still confused where can I obtain the library.
I know Core Graphics / Core Animation / QuartzCore Framework may help, as hinted by this tutorial. So, assuming the effect is based on a UITableView
, how can I distort the UITableViewCell
like the screenshot above?
I can make curved table cell by:
- (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;
}
but I have no clue how to make it responsive to scrolling.
My Question is: in short, how can I make curved UITableViewCell
when scrolling?
There are more SO questions I read:
- Animate a point of a Bezier curve
- How to move a view along a curved path in iOS
- iOS CoreGraphics: Draw arc, determine arc angles from intersecting chord theorem
and some tutorials:
- http://www.raywenderlich.com/33193/core-graphics-tutorial-arcs-and-paths
- http://nachbaur.com/blog/core-animation-part-4
Note: I'm working on iOS 7+ only.