SWIFT | OBJECTIVE-C |
---|
FSPagerView is an elegant Screen Slide Library implemented primarily with UICollectionView. It is extremely helpful for making Banner、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders.
- Infinite scrolling.
- Automatic Sliding.
- Support Horizontal and Vertical paging.
- Fully customizable item, with predefined banner-style item.
- Fully customizable page control.
- Rich build-in 3D transformers.
- Simple and Delightful api usage.
- Support SWIFT and OBJECTIVE-C.
Banner |
---|
The time interval of automatic sliding. 0 means disabling automatic sliding. Default is 0.
e.g.
pagerView.automaticSlidingInterval = 3.0;
A boolean value indicates whether the pager view has infinite number of items. Default is false.
e.g.
pagerView.isInfinite = YES;
The item size of the pager view. .zero means always fill the bounds of the pager view. Default is .zero.
e.g.
pagerView.itemSize = CGSizeMake(200, 180);
The spacing to use between items in the pager view. Default is 0.
e.g.
pagerView.interitemSpacing = 10;
Cross Fading |
---|
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeCrossFading];
Zoom Out |
---|
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeZoomOut];
Depth |
---|
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeDepth];
Linear |
---|
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeLinear];
Overlap |
---|
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeOverlap];
Ferris Wheel |
---|
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeFerrisWheel];
Inverted Ferris Wheel |
---|
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeInvertedFerrisWheel];
Cover Flow |
---|
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeCoverFlow];
Cubic |
---|
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeCubic];
Customize your own transformer by subclassing
FSPagerViewTransformer.
Page Control |
---|
|
The number of page indicators of the page control. Default is 0.
e.g.
pageControl.numberOfPages = 5;
The current page, highlighted by the page control. Default is 0.
e.g.
pageControl.currentPage = 1;
The horizontal alignment of content within the control’s bounds. Default is center.
e.g.
pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
Sets the stroke color for page indicators to use for the specified state. (selected/normal).
e.g.
[pageControl setStrokeColor:[UIColor greenColor] forState:UIControlStateNormal];
[pageControl setStrokeColor:[UIColor yellowColor] forState:UIControlStateSelected];
Sets the fill color for page indicators to use for the specified state. (selected/normal).
e.g.
[pageControl setFillColor:[UIColor grayColor] forState:UIControlStateNormal];
[pageControl setFillColor:[UIColor whiteColor] forState:UIControlStateSelected];
Sets the image for page indicators to use for the specified state. (selected/normal).
e.g.
[pageControl setImage:[UIImage imageNamed:@"image1"] forState:UIControlStateNormal];
[pageControl setImage:[UIImage imageNamed:@"image2"] forState:UIControlStateSelected];
Sets the path for page indicators to use for the specified state. (selected/normal).
e.g.
[pageControl setPath:[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 8, 8)] forState:UIControlStateNormal];
[pageControl setPath: [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 8, 8)] forState:UIControlStateSelected];
- Manually
- Cocoapods
- Carthage
- Download the source code.
- Extract the zip file, simply drag folder Sources into your project.
- Make sure Copy items if needed is checked.
use_frameworks!
target '<Your Target Name>' do
pod 'FSPagerView'
end
github "WenchaoD/FSPagerView"
- Getting started with code
// Create a pager view
FSPagerView *pagerView = [[FSPagerView alloc] initWithFrame:frame1];
pagerView.dataSource = self;
pagerView.delegate = self;
[pagerView registerClass:[FSPagerViewCell class] forCellWithReuseIdentifier:@"cell"];
[self.view addSubview:pagerView];
// Create a page control
FSPageControl *pageControl = [[FSPageControl alloc] initWithFrame:frame2];
[self.view addSubview:pageControl];
- Getting started with Interface Builder
1、Simply drag UIView instance into your View Controller, Change theCustom Class
toFSPagerView
. (OrFSPageControl
)
2、Link thedataSource
anddelegate
property of FSPagerView to your View Controller.
3、Register a cell class.
- (void)viewDidLoad {
[self.pagerView registerClass:[FSPagerViewCell class] forCellWithReuseIdentifier:@"cell"];
}
- (NSInteger)numberOfItemsInpagerView:(FSPagerView *)pagerView
{
return numberOfItems;
}
- (FSPagerViewCell *)pagerView:(FSPagerView *)pagerView cellForItemAtIndex:(NSInteger)index
{
FSPagerViewCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"cell" atIndex:index];
cell.imageView.image = ...;
cell.textLabel.text = ...;
return cell;
}
- (BOOL)pagerView:(FSPagerView *)pagerView shouldHighlightItemAtIndex:(NSInteger)index;
Asks the delegate if the item should be highlighted during tracking.
- (void)pagerView:(FSPagerView *)pagerView didHighlightItemAtIndex:(NSInteger)index;
Tells the delegate that the item at the specified index was highlighted.
- (BOOL)pagerView:(FSPagerView *)pagerView shouldSelectItemAtIndex:(NSInteger)index;
Asks the delegate if the specified item should be selected.
- (void)pagerView:(FSPagerView *)pagerView didSelectItemAtIndex:(NSInteger)index;
Tells the delegate that the item at the specified index was selected.
- (void)pagerView:(FSPagerView *)pagerView willDisplayCell:(FSPagerViewCell *)cell forItemAtIndex:(NSInteger)index;
Tells the delegate that the specified cell is about to be displayed in the pager view.
- (void)pagerView:(FSPagerView *)pagerView didEndDisplayingCell:(FSPagerViewCell *)cell forItemAtIndex:(NSInteger)index;
Tells the delegate that the specified cell was removed from the pager view.
- (void)pagerViewWillBeginDragging:(FSPagerView *)pagerView;
Tells the delegate when the pager view is about to start scrolling the content.
- (void)pagerViewWillEndDragging:(FSPagerView *) pagerView targetIndex:(NSInteger)index:
Tells the delegate when the user finishes scrolling the content.
- (void)pagerViewDidScroll:(FSPagerView *)pagerView;
Tells the delegate when the user scrolls the content view within the receiver.
- (void)pagerViewDidEndScrollAnimation:(FSPagerView *)pagerView;
Tells the delegate when a scrolling animation in the pager view concludes.
- (void)pagerViewDidEndDecelerating:(FSPagerView *)pagerView;
Tells the delegate that the pager view has ended decelerating the scrolling movement.
ˉ