iPhone: Expand UITextView when scrolling

2019-08-28 17:17发布

问题:

in my iPhone Application I have a UIImageView on the top and a UITextView below that. I want the UITextView to expand to the upper site and cover the UIImageView once the User starts scrolling.

A similar effect can be found in the Rdio Application. There you can view the cover on the top and the upcoming title below, once the user starts to scroll, the upcoming titles view expands and covers the cover.

How can that be done?

Thanks.

回答1:

Try to use one of the delegate methods of UIScrollView (UITextView is a subview of UIScrollView).

This should work for you:

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
    // From Apple Docs: Tells the delegate when the scroll view is about to start scrolling the content.

Implement this method and call your resizing function in it.