I have a UITableView with custom subviews in its cells. When a user does swipe-to-delete gesture on a cell my view is shrunk for a moment while the “Delete” button is being appeared.
As I understand it happens due to some system animation which takes place when the “Delete” button is to be appeared and my subview needs to become shorter. I set my subview’s contentMode to UIViewContentModeRedraw and everything looks fine after animation is finished.
I looked how this works in build-in Mail application and everything is fine there.
How can I avoid this shrinking? Is it possible to change this animation to “fade out” or something? Or can I handle a moment when this animation is started to make my subview shorter right away?
SOLUTION:
Finally I found a solution by subclassing UITableViewCell and overriding layoutSubviews method in the following way:
- (void)layoutSubviews
{
[super layoutSubviews];
UIView *view = [self.contentView viewWithTag:101];
CATransition *animation = [CATransition animation];
animation.duration = 0.2f;
animation.type = kCATransitionFade;
[view.layer removeAllAnimations];
[view.layer addAnimation: animation forKey:@"deletingFade"];
}
Thanks!
Override
layoutSubviewsmethod inUITableViewCellderived class and update positions for all your subviews accordingly tocontentView.bounds.sizeof the cell.