I found a solution for my problem, there may well be a better solution, but actually it works very well :)
Before starting the animation, I see that contentSize.height is greater than the height of the target, if so I do the following:
if (mMessages.contentSize.height > 150.f) { CGFloat expandedOffsetY = 52.f; CGFloat collapsedBottomOffset = (150.f + 18.f); CGFloat expandedBottomOffset = (MIN(320.f, mMessages.contentSize.height) + expandedOffsetY); tableFrame.origin.y = (collapsedBottomOffset - expandedBottomOffset) + expandedOffsetY; } else { tableFrame.origin.y = 18.f; tableFrame.size.height = 150.f; }
this will cause the tableview to be presented in minus origin.y, then I wrapped the table in the βparentβ uiview with clip signatures = YES.
Then I have a "completed" animation block that is "reset" to the target values.
CGRect tableFrame = mMessages.frame; tableFrame.origin.y = 18.f; tableFrame.size.height = 150.f; mMessages.frame = tableFrame; if (mMessages.contentSize.height > tableFrame.size.height) { float contentOffsetY = mMessages.contentSize.height - tableFrame.size.height; mMessages.contentOffset = CGPointMake(0.0f, contentOffsetY); }
source share