The iOS 7 redesign resulted in change of the view hierarchy of UITableViewCells
. The content view of the cell was wrapped in a private class called UITableViewCellScrollView
.
In iOS 7 UITableViewCellScrollView
has clipsToBounds
set to YES
and UITableViewCellContentView
has clipToBounds
set to NO
.
In iOS 7.1 UITableViewCellScrollView
has clipsToBounds
set to NO
and UITableViewCellContentView
has clipToBounds
set to NO.
If you call [[self contentView] setClipsToBounds:YES]
in iOS 7.1 is does it stick. By the time layoutSubviews is called on the cell UITableViewCellContentView has clipToBounds set to NO again.
[[self contentView] superview] setClipsToBounds:YES]
works in iOS 7.1 and sets UITableViewCellScrollView's clipToBounds to YES but this is a very brittle solution.
Overriding layoutSubview on the cell and calling [[self contentView] setClipsToBounds:YES]
works but is another fraile solution.
Does anyone know why this change has been made and a more robust solution to it?
As discussed in the comments, the only solution right now in iOS7.1 is to set clipsToBounds
on the cell itself.
It's quite annoying. What I did is add an UIView in the contentView with identical size (and autoresizingMask in width), add the relevant content to this view, and set clipsToBounds to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With