Search code examples
iphoneobjective-cuiscrollview

How to reduce the size of uiscrollview from top


I am creating a music application in which I am adding a scrollview to uiview, and another view is without scrollview. I want to reduce the size of scrollview from top. When I reduce the size of scrollview it gets reduced from bottom and that is a problem.

This is my code for scrollview:

scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,360)];
[[self view] addSubview:scroll];
[scroll setScrollEnabled:YES];
[scroll setBounces:NO];
[scroll setAlwaysBounceHorizontal:NO];

First the size of scrollview was 320,400 I reduced it by 40 and made it to 360 and so it get reduced from bottom. I want it should get reduced from top. How it is possible?


Solution

  • Well, if you reduce the size of the view but you want the bottom to remain at the same coordinate you just need to adapt the y coordinate accordingly as in:

    scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,40,320,360)];