0

I have one scrollview ,on that I am using imageview. I have horizontal scrollview size of 320 width and 40 pixel height.

I have number of images on scrollview.

I want when image comes center of scrollview,the size of image should increases by 40% in scale.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Prashant Shukla
  • 264
  • 3
  • 5

2 Answers2

0

implement timer in viewDidLoad:

NSTimer *t;
[t scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(timerFired1:) userInfo:nil repeats:YES];

create a callback for timer:

- (void)timerFired1:(NSTimer *)timer { 

if (clubScrollView.contentOffset.y + clubScrollView.frame.size.heigth/2 == yourImage.frame.center)
    [UIView animateWithDuration:1 
                     animations:^{
                          [YourImage setFrame:CGRectMake(x, y, width, height)];   //set any frame
                     }];
 }

invalidate timer in viewWillDisappear:

[t invalidate];
SentineL
  • 4,682
  • 5
  • 19
  • 38
  • Cant post more code without your one. How do you scrolling scrollView? via touches, or programmatically, via buttons? – SentineL Dec 01 '11 at 13:16
  • This is my code, and I am using IBOutlet for ScrollView . NSUInteger i; for (i = 1; i <= NIMAGE; i++) { NSString *imageName = [NSString stringWithFormat:@"image%d.png", i]; UIImage *image = [UIImage imageNamed:imageName]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, clubScrollView.frame.size.width,clubScrollView.frame.size.height-10)]; [imageView setImage:image]; [clubScrollView addSubview:imageView]; [imageView release]; } – Prashant Shukla Dec 02 '11 at 04:47
  • you need `UIView` as your clubScrollView's subview, and add your images as this UIView's subview. Also, on every step of your `for` cicle, make frame of this `UIView` bigger, and set clubScrollView's `contentSize` property bigger. Then, modify your question with this code – SentineL Dec 02 '11 at 05:06
  • I have done with Whatever you told but how to increase scale. – Prashant Shukla Dec 02 '11 at 05:21
  • What do you mean by yourImage here.This is UIImage or UIImageView? – Prashant Shukla Dec 02 '11 at 06:54
  • I mean UIImageView. You nedd better understanding of objective-c. you can not set frame to UIImage class – SentineL Dec 02 '11 at 08:21
0

Your imageviews would be better considered as in the scrollview not on it. So you could make the scrollview as high as the scaled up size of the images. You will I imagine place the images central vertically. Your scrollview would be in a viewcontroller that is the scrollviews delegate. The viewcontroller could then check the scrollviews offset to determine which image is in the centre and make sure it is scaled up, and make sure all other images are scaled down.

Your next problem would be looping the scrollview

Community
  • 1
  • 1
ader
  • 5,403
  • 1
  • 21
  • 26