XZPageControl
Example
To run the example project, clone the repo, and run pod install
from the Pods directory first.
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
Requirements
iOS 11.0, Xcode 14.0
Installation
XZPageControl is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'XZPageControl'
Author
Xezun, [email protected]
License
XZPageControl is available under the MIT license. See the LICENSE file for more info.