Reputation: 3789
I have a UITableViewCell and I animate it's content out and in. But I want to limit the animation so that when the text goes outside of the UITableViewCell it's not visible in the ViewController.
The animation itself is simple:
[UIView animateWithDuration:0.3 delay:0 options:0 animations:^
{
yesNew.origin.x += 200;
noNew.origin.x += 200;
ansLblNew.origin.x = -210;
[yesButton setFrame:yesNew];
[noButton setFrame:noNew];
[answerLabel setFrame:ansLblNew];
}completion:^(BOOL finished){
[yesButton setHidden:YES];
[noButton setHidden:YES];
[answerLabel setHidden:YES];
}];
Upvotes: 1
Views: 147
Reputation: 2282
How are you adding these subviews to your UITableViewCell
? Are you adding them to cell.contentView
? If so, you should be able to set cell.contentView.clipsToBounds = YES
. I've experienced weird behavior in the past when I've tried to set clipsToBounds
on the cell itself. Alternatively, have you tried setting myTableView.clipsToBounds=YES
? This is untested, but it may do the trick.
Upvotes: 0
Reputation: 104092
Try setting clipToBounds to YES for your cell (if you're doing it in code), or check the "Clip Subviews" check box in IB (in the "view" section of the attributes inspector).
Upvotes: 2