iCarousel-ピクチャー輪番

2180 ワード

オープンソースアドレス:https://github.com/nicklockwood/iCarousel
切り替え効果は特別で、一般的な切り替え効果ではなく、pageControlはありません.効果は上のサイトで確認できます.
単純な使用
  • 初期化
  •         _banner = [iCarousel new];
            _banner.type = iCarouselTypeCylinder;//           ,     reload
            _banner.delegate = self;
            _banner.dataSource = self;
    
            /*
             typedef NS_ENUM(NSInteger, iCarouselType)
             {
             iCarouselTypeLinear = 0,   ,   
             iCarouselTypeRotary,   ,  
             iCarouselTypeInvertedRotary,  ,  
             iCarouselTypeCylinder,   ,  
             iCarouselTypeInvertedCylinder,  ,  
             iCarouselTypeWheel,  ,  ,     。
             iCarouselTypeInvertedWheel,  ,  ,     。
             iCarouselTypeCoverFlow,      
             iCarouselTypeCoverFlow2,  2,   
             iCarouselTypeTimeMachine,    ,   
             iCarouselTypeInvertedTimeMachine,   ,   
             iCarouselTypeCustom
             };
             */
    
  • 共通エージェント
  • -(NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel{
        return [self.dataSource count];
    }
    
    -(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view{
        if (view == nil) {
            UIView *colorView = [UIView new];
            colorView.backgroundColor = self.dataSource[index];
            colorView.frame = CGRectMake(0, 0, 300, CGRectGetHeight(carousel.bounds));
            return colorView;
        }else{
            view.backgroundColor = self.dataSource[index];
            return view;
        }
        return nil;
    }
    
    - (void)carousel:(__unused iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index {
        NSLog(@"Tapped view number: %ld", (long)index);
    }
    
    - (void)carouselCurrentItemIndexDidChange:(__unused iCarousel *)carousel {
        NSLog(@"Index: %@", @(self.banner.currentItemIndex));
    }
     
    
  • 自分でpageControl
  • を追加
    //         (          0 )
        if (index == [self.dataSource count] - 1) {
            [carousel scrollToItemAtIndex:0 animated:YES];
        } else {
            [carousel scrollToItemAtIndex:index+1 animated:YES];
        }
    

    その他
    その他のプロパティやエージェントはたくさんあります.深く使われておらず、カスタム3 D回転場もひざまずいた.一般的な使用差は多くありません.研究を待つ.
    1