What I have is list of images. I was showing those images in scrollview with paging enabled.
Now client came back asking too show next (partly visible), current (fully visible) and previous (partly visible) images as shown in below image.
(source: mzstatic.com)
What I tried is as below.
int mm = 150;
for (int i=0;i<featuredProductArray.count;i++) {
UIButton *mButton = [UIButton buttonWithType:UIButtonTypeCustom];
[mButton addTarget:self action:@selector(takeMeToProductDetails:) forControlEvents:UIControlEventTouchUpInside];
mButton.imageView.contentMode = UIViewContentModeScaleAspectFill;
[mButton sd_setImageWithURL:[NSURL URLWithString:[[[featuredProductArray objectAtIndex:i] valueForKey:@"Image"] stringByReplacingOccurrencesOfString:@"/Original/" withString:@"/1080/"] ] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"slider_bg.png"]];
[mButton setAdjustsImageWhenHighlighted:NO];
mButton.accessibilityValue = [NSString stringWithFormat:@"feat%d", i];
mButton.frame = CGRectMake(mm*iPhoneFactorX, 0, 780*iPhoneFactorX, iPhoneHeight-(20+(149*iPhoneFactorX)));
mm = mm + 780+50;
[yScrollView addSubview:mButton];
}
Now I have paging issue.. when I scroll, the second image is not centered...
First of all disable the scrolling from the IB.
Now add images next to each other using for loop
Set scrollview contentSize
Create variable int myPostForSwipe and initialize to 0
Now add swipe gestures, which are very important
Implement didSwipeScreen
That's it
Another solution
The another solution is more and more simple...
Create UIScrollView of the middle image size
Un-tick Clip Subviews & tick Paging Enable (this is very important)
Fill scrollview with images now.
You are done!!!
This point didn't work with me bcz I had side menu & all the scrollview was spreading over side menu.
Let me know if anyone have any questions.