我正在使用 MCSwipeTableViewCell,所以这个想法是用户向左或向右滑动它来完成操作。但是,用户可能并不总是熟悉此操作,因此当他们点击单元格(期望选择它)时,我希望文本短暂闪烁一个简短的指令,然后返回原始文本。
我已经做了好几天了,一直没有运气。我试过使用完成块,玩延迟,各种但动画似乎完成得太快了你实际上没有看到变化,我做错了什么?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
MCSwipeTableViewCell *cell = (MCSwipeTableViewCell *)[self.tableView cellForRowAtIndexPath:indexPath];
Station *station = self.recentStations[indexPath.row];
[UIView animateWithDuration:0.5 animations:^{
//code to fade the text out
CATransition *animation = [CATransition animation];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.type = kCATransitionFade;
animation.duration = 0.35;
[cell.textLabel.layer addAnimation:animation forKey:@"kCATransitionFade"];
//instructions to appear briefly
cell.textLabel.text = @"Swipe left to set alarm or right to remove";
//nested animation to revert text after a 1.5 second delay
[UIView animateWithDuration:.05 delay:1.5 options:UIViewAnimationOptionCurveEaseIn animations:^{
//code to fade the text back in
CATransition *animation = [CATransition animation];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.type = kCATransitionFade;
animation.duration = 0.35;
[cell.textLabel.layer addAnimation:animation forKey:@"kCATransitionFade"];
cell.textLabel.text = station.name;
} completion:nil];
}];
}