Search code examples
iphoneuitextviewcgrect

iPhone CGRect - Get Frame Size?


I'm looking to find out the "lower limit" of a frame. The frame in question is a UITextView that resizes based on the size of the content e.g.

CGRect frame = mainTextBox.frame;
frame.size.height = mainTextBox.contentSize.height;
mainTextBox.frame = frame;

This works fine but it is the last item on a scrollView. So what I want to do is program the scroll view to only be as long as nessisary e.g.

[scrollView setContentSize:CGSizeMake(320,1850)]

What I want to do is make the 1850 the right size so that the scrollView finishes just below the mainTextBox.

Is there anyway to get a return as to the distance of the bottom of the frame to the top of the view?


Solution

  • Just add the y coordinate of the origin point (upper left corner of the view) to the height.

    CGFloat lowerBound = mainTextBox.frame.origin.y + mainTextBox.frame.size.height;