2013-02-25 136 views
-1

尋找教程後,看到很多關於滾動圖像的答案後,我很難實現UIScrollView,就像在選擇分隔符中的字符一樣。 在本卷中,對我感興趣的區域是小圖像。我想要做同樣的事情。iOS滾動圖像

另一個令我感興趣的例子應該是來自Itunes的coverflow,但是沒有左右兩邊的圖片。只是中心的圖像和相同的動畫。

感謝您的幫助! =)

+0

很少有人會知道什麼是分路器。張貼你想要的效果圖片。 – rmaddy 2013-02-25 23:44:08

+0

問題是,我幾乎沒有張貼圖片的聲望:/請改善它=) – user2057209 2013-02-26 11:44:22

回答

0
-(id)init{ 
    self = [super init]; 
    if (self){ 
    UIScrollView *scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(30, 155, 265, 180)]; 
     [scroller setBackgroundColor:[UIColor lightGrayColor]]; 
     [scroller setPagingEnabled:YES]; 
     [scroller setDelegate:self]; 
     [self addSubview:scroller]; 

    NSArray *arrayOfImages = [NSArray alloc] initWithObjects images, nil]; 
} 

-(void)setScrollView:(UIScrollView *)scroller1 :(NSArray *)array{ 
    for (int i = 0; i < array.count; i++) { 
     CGRect frame; 
     frame.origin.x = scroller.frame.size.width * i; 
     frame.origin.y = 0; 
     frame.size = scroller.frame.size; 

     UIImageView *newPageView = [[UIImageView alloc] initWithImage:[array objectAtIndex:i]]; 
     newPageView.contentMode = UIViewContentModeScaleAspectFit; 
     newPageView.frame = frame; 
     [scroller addSubview:newPageView]; 

    } 

    scroller.contentSize = CGSizeMake(scroller.frame.size.width * array.count, scroller.frame.size.height); 
} 

-(void)viewWillAppear:(BOOL)animated{ 
    [super viewWillAppear:animated]; 
    [self setScrollView:scroller :arrayOfImages]; 
} 

我相信這應該工作。這是一個scrollview並插入uiimageviews

+0

這工作正常!我已經放了一個UIButton,允許滾動圖像。這裏是以下代碼: - (void)ActionScroll {= {test * 265; [scroller setContentOffset:CGPointMake(X,0)animated:YES]; test ++; } – user2057209 2013-02-26 13:52:02