How to implement a uiscrollview with some small images?

Asked By 20 points N/A Posted on -
qa-featured

Hi,

With some small images, I'm attempting to implement a uiscrollview.

I require that uiscrollview's last picture in every end stay in the center when scroll stops, leaving one part empty.

Now, last picture remain in the areas when scroll ends.

I have to know which picture is in the middle of the scroll view, and I want to use a shadow on it.

jugadorSlide.pagingEnabled = YES;
NSError *error = nil;
fotosJugadores = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: @"/Users/exular/Developer/GBC/exular/GBC/Caras/" error: &error];

NSInteger numberOfViews = [fotosJugadores count];
for (int i = 0; i < numberOfViews; i++) {

    UIImage *myImage = [UIImage imageNamed:[fotosJugadores objectAtIndex:i]];
    CGFloat yOrigin = i * myImage.size.width;
    UIImageView *awesomeView = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, myImage.size.width, myImage.size.height)];
    awesomeView.alpha = 0.5;
    awesomeView.image = myImage;
    [self.jugadorSlide addSubview:awesomeView];
    awesomeView=nil;
}
jugadorSlide .contentSize = CGSizeMake(65 * numberOfViews,78);
jugadorSlide.layer.cornerRadius = 11;
jugadorSlide.layer.masksToBounds = YES;

Please help me to do this.

Thanks.

SHARE
Answered By 10 points N/A #149615

How to implement a uiscrollview with some small images?

qa-featured

Hallo Ann,

The following workarounds should help you.

Solution 1:

You should try making your scrollview in a manner that is less than the size of the screen as per its width, but then you will have to make sure that you uncheck the Clip Subviews checkbox in IB. After you have done that you should try overlaying a transparent, userInteractionEnabled = NO view on its top, which should be at full width, and it should be able to override hitTest:withEvent: so as it can return your scroll view.

Solution 2:

You ca try subclassing UIScrollView as well as overriding its pointInside. After you have done that, the scroll view can have response for touches outside its frame.

Regards,

Carl

Related Questions