XZPageView 1.1.0

XZPageView 1.1.0

Maintained by Xezun.



  • By
  • Xezun

XZPageView

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Pods directory first.

XZPageView 是一种支持横向翻页的视图组件,常见于轮播图,也可用于多 Tab 页面。

实现轮播图

与常用的轮播图组件相比,使用 XZPageView 可以提供更大的自由度,因为所有图片视图都是可以配置的。

// 创建视图
- (void)viewDidLoad {
    [super viewDidLoad];

    XZPageView *pageView = [[XZPageView alloc] initWithFrame:CGRectMake(0, 0, 375.0, 150.0)];
    [self.view addSubview:pageView];
    
    pageView.dataSource = self;
}

// 实现数据源方法

- (NSInteger)numberOfPagesInPageView:(XZPageView *)pageView {
    return self.imageURLs.count;
}

- (UIView *)pageView:(XZPageView *)pageView viewForPageAtIndex:(NSInteger)index reusingView:(UIImageView *)reusingView {
    if (reusingView == nil) {
        reusingView = [[UIImageView alloc] initWithFrame:pageView.bounds];
        // config the UIImageView here
    }
    [reusingView sd_setImageWithURL:self.imageURLs[index]];
    return reusingView;
}

- (nullable UIView *)pageView:(XZPageView *)pageView prepareForReusingView:(UIImageView *)reusingView {
    reusingView.image = nil; 
    return reusingView;
}

支持自动轮播及循环轮播。

self.pageView.isLoopable = YES;
self.pageView.autoPagingInterval = 3.0;

Requirements

iOS 11.0, Xcode 14.0

Installation

XZPageView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'XZPageView'

Author

Xezun, [email protected]

License

XZPageView is available under the MIT license. See the LICENSE file for more info.