Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set UIscrollView page size

I have been searching for how to make a scroll menu with a UIScrollview wraping (looping). I checked this question and the example works and maybe it's a good approach.

But instead of showing just one page (image) I need to display 3 pages and being able to scroll one page at time.

So how can I set the UIScrollView page size 1/3 smaller than the frame (I think this way it will work)??

Is it achievable?? If not, please direct me to another direction

Thanks

like image 657
Frade Avatar asked Aug 17 '26 00:08

Frade


2 Answers

I believe what you are talking about is having a portion of the previous page and a portion of the next page visible. The way to do this is to set the scroll view's frame to be what you want (less than the screen, for example) and then turn off clipping of subviews for your scroll view. This will achieve the effect you are after.

like image 148
brant Avatar answered Aug 18 '26 17:08

brant


  1. [theScrollView setFrame:<a frame>]; will set the frame of the scroll view
  2. [theScrollView setContentSize:<a Size>]; to set the content size of your scroll view

The size in 1. should be 1/3 of the size set in 2.

like image 39
Niko Avatar answered Aug 18 '26 15:08

Niko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!