XZPageControl
示例
要运行示例项目,请克隆仓库,并从 Pods 目录运行 pod install
。
XZPageControl 功能类似于 UIControl 组件,但它提供了自定义指示器外观的功能。
- (void)viewDidLoad {
[super viewDidLoad];
// 创建视图
UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 200, 375, 50.0)];
[self.view addSubview:pageControl];
// 绑定事件
[self.pageControl addTarget:self action:@selector(pageControlDidChangeValue:) forControlEvents:(UIControlEventValueChanged)];
}
// 处理事件
- (void)pageControlDidChangeValue:(XZPageControl *)pageControl {
[self.pageView setCurrentPage:pageControl.currentPage animated:YES];
}
支持自定义指示器外观。 默认情况下,指示器支持以下所有属性,并支持使用自定义组件。
@protocol XZPageControlIndicator <NSObject>
@property (nonatomic, setter=setCurrent:) BOOL isCurrent;
@optional
@property (nonatomic, strong, nullable) UIColor *strokeColor;
@property (nonatomic, strong, nullable) UIColor *currentStrokeColor;
@property (nonatomic, strong, nullable) UIColor *fillColor;
@property (nonatomic, strong, nullable) UIColor *currentFillColor;
@property (nonatomic, copy, nullable) UIBezierPath *shape;
@property (nonatomic, copy, nullable) UIBezierPath *currentShape;
@property (nonatomic, strong, nullable) UIImage *image;
@property (nonatomic, strong, nullable) UIImage *currentImage;
@end
要求
iOS 11.0, Xcode 14.0
安装
XZPageControl 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'XZPageControl'
作者
授权协议
XZPageControl 在 MIT 授权协议下可用。有关更多信息,请参阅 LICENSE 文件。