iOS輪播圖無限滾動

jopen 9年前發布 | 14K 次閱讀 IOS iOS開發 移動開發

輪播圖無限滾動

集成速度快、節省項目開發時間,提高效率的圖片無限輪播框架。

使用介紹

  • 只需創建輪播對象,把輪播圖添加到數組中即可實現
    // 輪播圖
    YLInfiniteScrollView *scrollView = [[YLInfiniteScrollView alloc] init];
    CGFloat scrollViewH = 200;
    CGFloat scrollViewW = [UIScreen mainScreen].bounds.size.width;
    // 輪播圖的位置和尺寸
    scrollView.frame = CGRectMake(0, 40, scrollViewW, scrollViewH);
    // 數組中添加輪播圖片
    scrollView.images = @[
                          [UIImage imageNamed:@"輪播圖1"],
                          [UIImage imageNamed:@"輪播圖2"],
                          [UIImage imageNamed:@"輪播圖3"],
                          [UIImage imageNamed:@"輪播圖4"]
                          ];
    [self.view addSubview:scrollView];

頭文件提供外界使用的方法

@protocol YLInfiniteScrollViewDelegate <NSObject>

@optional
- (void)scrollViewImageClick:(YLInfiniteScrollView *)scrollView;
@end

@interface YLInfiniteScrollView : UIView
/** 添加輪播圖片 */
@property (strong, nonatomic) NSArray *images;
/** 右下角的圓點提示 */
@property (weak, nonatomic, readonly) UIPageControl *pageControl;
/** 滾動方向 */
@property (assign, nonatomic, getter=isScrollDirectionPortrait) BOOL scrollDirectionPortrait;
/** 圖片被點擊 */
@property (weak, nonatomic) id<YLInfiniteScrollViewDelegate> delegate;
@end

項目主頁:http://www.baiduhome.net/lib/view/home/1449196068998

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!