Convert Figma logo to code with AI

WenchaoD logoFSPagerView

FSPagerView is an elegant Screen Slide Library. It is extremely helpful for making Banner View、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders.

7,164
957
7,164
177

Top Related Projects

11,999

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS

:octocat: ExpandingCollection is an animated material design UI card peek/pop controller. iOS library made by @Ramotion

5,370

KolodaView is a class designed to simplify the implementation of Tinder like cards on iOS.

:octocat: 📃 FoldingCell is an expanding content cell with animation made by @Ramotion

:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion

Quick Overview

FSPagerView is an elegant, high-performance, and fully customizable Swift library for creating paging views. It's designed to be a drop-in replacement for UIPageViewController with additional features and flexibility, making it ideal for creating image carousels, onboarding screens, or any other paging content in iOS applications.

Pros

  • Highly customizable with extensive configuration options
  • Smooth and efficient performance, even with large numbers of pages
  • Supports both infinite scrolling and bounded paging modes
  • Easy integration with UIKit and SwiftUI

Cons

  • Limited to iOS platform only
  • May require additional setup for complex layouts or animations
  • Documentation could be more comprehensive for advanced use cases
  • Relatively large codebase compared to simpler paging solutions

Code Examples

Creating a basic FSPagerView:

let pagerView = FSPagerView(frame: view.bounds)
pagerView.dataSource = self
pagerView.delegate = self
view.addSubview(pagerView)

Implementing the data source methods:

extension ViewController: FSPagerViewDataSource {
    func numberOfItems(in pagerView: FSPagerView) -> Int {
        return 5
    }
    
    func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
        let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index)
        cell.imageView?.image = UIImage(named: "image_\(index)")
        return cell
    }
}

Customizing the appearance:

pagerView.transformer = FSPagerViewTransformer(type: .zoomOut)
pagerView.itemSize = CGSize(width: 200, height: 300)
pagerView.decelerationDistance = 1

Getting Started

  1. Install FSPagerView using CocoaPods, Carthage, or Swift Package Manager.
  2. Import the library in your Swift file:
    import FSPagerView
    
  3. Create an instance of FSPagerView and add it to your view hierarchy:
    let pagerView = FSPagerView(frame: view.bounds)
    view.addSubview(pagerView)
    
  4. Set up the data source and delegate:
    pagerView.dataSource = self
    pagerView.delegate = self
    
  5. Implement the required data source methods to provide content for the pager view.
  6. Customize the appearance and behavior using the various properties and methods provided by FSPagerView.

Competitor Comparisons

11,999

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS

Pros of iCarousel

  • More customizable with a wide range of carousel types and options
  • Supports both 2D and 3D transformations for unique visual effects
  • Longer development history and larger community support

Cons of iCarousel

  • Written in Objective-C, which may be less appealing for Swift-only projects
  • Last updated in 2018, potentially lacking support for newer iOS versions
  • More complex API, which can lead to a steeper learning curve

Code Comparison

FSPagerView:

let pagerView = FSPagerView(frame: frame)
pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
pagerView.itemSize = CGSize(width: 200, height: 300)
pagerView.transformer = FSPagerViewTransformer(type: .linear)

iCarousel:

iCarousel *carousel = [[iCarousel alloc] initWithFrame:frame];
carousel.type = iCarouselTypeLinear;
carousel.delegate = self;
carousel.dataSource = self;
[self.view addSubview:carousel];

Both libraries offer easy-to-use carousel implementations, but FSPagerView provides a more modern Swift-based approach with a simpler API, while iCarousel offers more customization options and transformation types at the cost of complexity and being written in Objective-C.

:octocat: ExpandingCollection is an animated material design UI card peek/pop controller. iOS library made by @Ramotion

Pros of expanding-collection

  • More visually appealing with its expanding card animation
  • Offers a unique and interactive user experience
  • Includes additional features like custom transitions and card layouts

Cons of expanding-collection

  • Less actively maintained (last update was 3 years ago)
  • More complex implementation due to advanced features
  • Limited customization options compared to FSPagerView

Code Comparison

FSPagerView:

let pagerView = FSPagerView(frame: frame)
pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
pagerView.itemSize = CGSize(width: 200, height: 300)
pagerView.dataSource = self
pagerView.delegate = self

expanding-collection:

let layout = ExpandingCollectionViewLayout()
let collectionView = UICollectionView(frame: frame, collectionViewLayout: layout)
collectionView.register(ExpandingCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
collectionView.dataSource = self
collectionView.delegate = self

Both libraries provide similar functionality for creating paging views or collections, but expanding-collection offers more advanced animations and transitions at the cost of simplicity. FSPagerView is more actively maintained and provides a wider range of customization options, making it suitable for various use cases. The choice between the two depends on the specific requirements of your project and the desired user experience.

5,370

KolodaView is a class designed to simplify the implementation of Tinder like cards on iOS.

Pros of Koloda

  • More customizable UI with advanced animations and gestures
  • Better suited for Tinder-like card swiping interfaces
  • Supports both Swift and Objective-C

Cons of Koloda

  • Less flexible for general carousel or pager views
  • Steeper learning curve due to more complex API
  • Less frequent updates and maintenance

Code Comparison

Koloda:

let kolodaView = KolodaView()
kolodaView.dataSource = self
kolodaView.delegate = self

func kolodaNumberOfCards(_ koloda: KolodaView) -> Int {
    return images.count
}

FSPagerView:

let pagerView = FSPagerView()
pagerView.dataSource = self
pagerView.delegate = self

func numberOfItems(in pagerView: FSPagerView) -> Int {
    return images.count
}

Both libraries use similar patterns for setting up the view and implementing data source methods. However, Koloda's API is more focused on card-swiping interactions, while FSPagerView offers a more general-purpose pager view with additional customization options for transformations and layouts.

FSPagerView is better suited for creating traditional carousel or pager views with various transition effects, while Koloda excels at creating Tinder-like card swiping interfaces with more advanced gesture recognition and animations. The choice between the two depends on the specific requirements of your project and the desired user interaction style.

:octocat: 📃 FoldingCell is an expanding content cell with animation made by @Ramotion

Pros of folding-cell

  • Unique and visually appealing folding animation effect
  • Customizable content for both folded and unfolded states
  • Supports Swift and can be easily integrated into iOS projects

Cons of folding-cell

  • Limited to a specific UI pattern, less versatile than FSPagerView
  • May require more setup and customization for complex use cases
  • Not suitable for horizontal scrolling or paging scenarios

Code Comparison

FSPagerView:

let pagerView = FSPagerView(frame: frame)
pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
pagerView.itemSize = CGSize(width: 200, height: 300)
pagerView.dataSource = self
pagerView.delegate = self

folding-cell:

let cell = FoldingCell()
cell.itemCount = 2
cell.delegate = self
cell.foregroundView = customForegroundView
cell.containerView = customContainerView

Summary

FSPagerView is a versatile paging view library suitable for various scrolling and paging scenarios, while folding-cell offers a specific, visually appealing folding animation effect. FSPagerView provides more flexibility for different use cases, whereas folding-cell excels in creating an engaging, expandable cell UI. The choice between the two depends on the specific design requirements and functionality needed in your iOS application.

:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion

Pros of animated-tab-bar

  • Offers animated and visually appealing tab bar transitions
  • Provides a wide range of customizable animations and icons
  • Enhances user experience with interactive tab switching

Cons of animated-tab-bar

  • Limited to tab bar functionality, less versatile than FSPagerView
  • May have a steeper learning curve due to animation complexity
  • Potentially higher performance overhead due to animations

Code Comparison

FSPagerView:

let pagerView = FSPagerView(frame: frame)
pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
pagerView.itemSize = CGSize(width: 200, height: 300)
pagerView.dataSource = self
pagerView.delegate = self

animated-tab-bar:

let tabBar = RAMAnimatedTabBarController()
let item1 = RAMAnimatedTabBarItem(title: "Home", image: UIImage(named: "home"), tag: 1)
item1.animation = RAMBounceAnimation()
tabBar.viewControllers = [UIViewController()]
tabBar.setViewControllers([UIViewController()], animated: true)

Both libraries offer unique functionalities for iOS development. FSPagerView focuses on creating customizable pager views, while animated-tab-bar specializes in enhancing tab bar interactions with animations. The choice between the two depends on the specific requirements of your project, whether you need a versatile pager view or an animated tab bar interface.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

fspagerview

Languages
Platform Version Carthage compatible SPM compatible

SWIFTOBJECTIVE-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.

Features

  • Infinite scrolling.
  • Automatic Sliding.
  • 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.

Demos

Demo1 - Banner

Banner
9

automaticSlidingInterval

The time interval of automatic sliding. 0 means disabling automatic sliding. Default is 0.

e.g.

pagerView.automaticSlidingInterval = 3.0

isInfinite

A boolean value indicates whether the pager view has infinite number of items. Default is false.

e.g.

pagerView.isInfinite = true

decelerationDistance

An unsigned integer value that determines the paging distance of the pager view, which indicates the number of passing items during the deceleration. When the value of this property is FSPagerView.automaticDistance, the actual 'distance' is automatically calculated according to the scrolling speed of the pager view. Default is 1.

e.g.

pagerView.decelerationDistance = 2

itemSize

The item size of the pager view. When the value of this property is FSPagerView.automaticSize, the items fill the entire visible area of the pager view. Default is FSPagerView.automaticSize.

e.g.

pagerView.itemSize = CGSize(width: 200, height: 180)

interitemSpacing

The spacing to use between items in the pager view. Default is 0.

e.g.

pagerView.interitemSpacing = 10

Demo2 - Transformers

Cross Fading
1
pagerView.transformer = FSPagerViewTransformer(type: .crossFading)

Zoom Out
2
pagerView.transformer = FSPagerViewTransformer(type: .zoomOut)

Depth
3
pagerView.transformer = FSPagerViewTransformer(type: .depth)

Linear
4
pagerView.transformer = FSPagerViewTransformer(type: .linear)

Overlap
5
pagerView.transformer = FSPagerViewTransformer(type: .overlap)

Ferris Wheel
6
pagerView.transformer = FSPagerViewTransformer(type: .ferrisWheel)

Inverted Ferris Wheel
7
pagerView.transformer = FSPagerViewTransformer(type: .invertedFerrisWheel)

Cover Flow
8
pagerView.transformer = FSPagerViewTransformer(type: .coverFlow)

Cubic
9
pagerView.transformer = FSPagerViewTransformer(type: .cubic)

Customize your own transformer by subclassingFSPagerViewTransformer.

Demo3 Page Control

Page Control
10

numberOfPages

The number of page indicators of the page control. Default is 0.

e.g.

pageControl.numberOfPages = 5

currentPage

The current page, highlighted by the page control. Default is 0.

e.g.

pageControl.currentPage = 1

contentHorizontalAlignment

The horizontal alignment of content within the control’s bounds. Default is center.

e.g.

pageControl.contentHorizontalAlignment = .right

setStrokeColor:forState:

Sets the stroke color for page indicators to use for the specified state. (selected/normal).

e.g.

pageControl.setStrokeColor(.green, for: .normal)
pageControl.setStrokeColor(.yellow, for: .selected)

setFillColor:forState:

Sets the fill color for page indicators to use for the specified state. (selected/normal).

e.g.

pageControl.setFillColor(.gray, for: .normal)
pageControl.setFillColor(.white, for: .selected)

setImage:forState:

Sets the image for page indicators to use for the specified state. (selected/normal).

e.g.

pageControl.setImage(UIImage(named:"image1"), for: .normal)
pageControl.setImage(UIImage(named:"image2"), for: .selected)

setPath:forState:

Sets the path for page indicators to use for the specified state. (selected/normal).

e.g.

pageControl.setPath(UIBezierPath(rect: CGRect(x: 0, y: 0, width: 8, height: 8)), for: .normal)
pageControl.setPath(UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: 8, height: 8)), for: .selected)

Installation

  • Manually
  • Cocoapods
  • Carthage

Manually

  1. Download the source code.
  2. Extract the zip file, simply drag folder Sources into your project.
  3. Make sure Copy items if needed is checked.

Cocoapods

use_frameworks!
target '<Your Target Name>' do
    pod 'FSPagerView'
end

Carthage

github "WenchaoD/FSPagerView"

Tutorial

1. Getting started

  • Getting started with code
// Create a pager view
let pagerView = FSPagerView(frame: frame1)
pagerView.dataSource = self
pagerView.delegate = self
pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
self.view.addSubview(pagerView)
// Create a page control
let pageControl = FSPageControl(frame: frame2)
self.view.addSubview(pageControl)
  • Getting started with Interface Builder
    1、Simply drag UIView instance into your View Controller, Change the Custom Class to FSPagerView. (Or FSPageControl)
    2、Link the dataSource and delegate property of FSPagerView to your View Controller.
    3、Register a cell class.
@IBOutlet weak var pagerView: FSPagerView! {
    didSet {
        self.pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
    }
}

2. Implement FSPagerViewDataSource

public func numberOfItems(in pagerView: FSPagerView) -> Int {
    return numberOfItems
}
    
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
    let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index)
    cell.imageView?.image = ...
    cell.textLabel?.text = ...
    return cell
}

3. Implement FSPagerViewDelegate

func pagerView(_ pagerView: FSPagerView, shouldHighlightItemAt index: Int) -> Bool

Asks the delegate if the item should be highlighted during tracking.


func pagerView(_ pagerView: FSPagerView, didHighlightItemAt index: Int)

Tells the delegate that the item at the specified index was highlighted.


func pagerView(_ pagerView: FSPagerView, shouldSelectItemAt index: Int) -> Bool

Asks the delegate if the specified item should be selected.


func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int)

Tells the delegate that the item at the specified index was selected.


func pagerView(_ pagerView: FSPagerView, willDisplay cell: FSPagerViewCell, forItemAt index: Int)

Tells the delegate that the specified cell is about to be displayed in the pager view.


func pagerView(_ pagerView: FSPagerView, didEndDisplaying cell: FSPagerViewCell, forItemAt index: Int)

Tells the delegate that the specified cell was removed from the pager view.


func pagerViewWillBeginDragging(_ pagerView: FSPagerView)

Tells the delegate when the pager view is about to start scrolling the content.


func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int)

Tells the delegate when the user finishes scrolling the content.


func pagerViewDidScroll(_ pagerView: FSPagerView)

Tells the delegate when the user scrolls the content view within the receiver.


func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView)

Tells the delegate when a scrolling animation in the pager view concludes.


func pagerViewDidEndDecelerating(_ pagerView: FSPagerView)

Tells the delegate that the pager view has ended decelerating the scrolling movement.


Support this repo

  • Star this repo star


  • Buy me a Coffee. ☕️

      |     |  


Author


Documentation