Super Simple Pager with RxSwift extension

Overview

SSPager

Languages Platform Version SPM compatible

Super Simple Pager

Example

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

Installation

CocoaPods

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

pod 'SSPager', '~> 1.0.0'

Swift Package Manager

Create a Package.swift file.

import PackageDescription

let package = Package(
  name: "SSPager",
  dependencies: [
    .package(url: "https://github.com/9oya/SSPager.git", from: "1.0.0")
  ],
  targets: [
      .target(
          name: "SSPager",
          path: "SSPager"
      )
  ]
)

Usage

@IBOutlet weak var pagerView: SSPagerView!
pagerView.dataSource = self
pagerView.delegate = self
pagerView.register(SSPagerViewCell.self, forCellWithReuseIdentifier: "SSPagerViewCell"))

DataSource

func numberOfPages(_ pagerView: SSPagerView) -> Int

func pagerView(_ pagerView: SSPagerView, cellForItemAt index: Int) -> SSPagerViewCell

Paging Option

pagerView.interitemSpacing = 20.0
pagerView.isInfinite = true
pagerView.automaticSlidingInterval = 2.0
pagerView.pagingMode = .oneStep // .scrollable .disable
pagerView.itemSize = CGSize(width: cellWidth, // view.frame.width * 0.7
                            height: cellHeight) // view.frame.height * 0.7 
pagerView.contentsInset = UIEdgeInsets(top: 100,
                                       left: (view.bounds.width - cellWidth) / 2,
                                       bottom: 100,
                                       right: (view.bounds.width - cellWidth) / 2)

Control

func scrollToPage(at index: Int, animated: Bool)

Delegate

func pagerViewDidSelectPage(at index: Int)

func pagerViewWillEndDragging(_ scrollView: UIScrollView, targetIndex: Int)

Rx

SSPager provide a subspec SSPager/Rx

pod 'SSPager/Rx', '~> 1.0.0'
@IBOutlet weak var pagerView: SSPagerView!
/* 
You don't need to set delegate and datasource
`pagerView.dataSource = self`
`pagerView.delegate = self`
*/
pagerView.register(SSPagerViewCell.self, forCellWithReuseIdentifier: "SSPagerViewCell")

Binding:

// let itemColors = [UIColor.red, UIColor.orange, UIColor.yellow, UIColor.green, UIColor.blue]

Observable.just(itemColors)
    .bind(to: pagerView.rx.pages(cellIdentifier: defaultCellId)) 
    { idx, color, cell in
        cell.backgroundColor = color
    }
    .disposed(by: disposeBag)
        
pagerView.rx.pageSelected
    .bind(onNext: { idx in
        print("Page \(idx) is selected.")
    })
    .disposed(by: disposeBag)

Author

Eido Goya, [email protected]

License

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

You might also like...
RxSwift extensions for Core Data

RxCoreData Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Xcode 9.0 Swift 4.0

🤖 RxSwift + State Machine, inspired by Redux and Elm.
🤖 RxSwift + State Machine, inspired by Redux and Elm.

RxAutomaton RxSwift port of ReactiveAutomaton (State Machine). Terminology Whenever the word "signal" or "(signal) producer" appears (derived from Rea

RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with API's easier than ever reactively.
RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with API's easier than ever reactively.

Written in Swift 5 RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with

Support Combine Assign subscriber in RxSwift.

RxAssign Support Combine Assign subscriber in RxSwift. Assign uses a KeyPath which is really nice and useful. ** RxAssign extends Driver and Signal in

This is the demo of MVVM-C structure with dependency injection using RxSwift.
This is the demo of MVVM-C structure with dependency injection using RxSwift.

MVVMC-Demo Demo defination This is the demo project, I have integrated two APIs for MovieDB APIS (https://www.themoviedb.org/). One for the listing of

Simple and lightweight Functional Reactive Coding in Swift for the rest of us
Simple and lightweight Functional Reactive Coding in Swift for the rest of us

The simplest ObservableT implementation for Functional Reactive Programming you will ever find. This library does not use the term FRP (Functional R

Simple, lightweight swift bindings

Bindy Just a simple bindings. Installation Add pod 'Bindy' to your podfile, and run pod install SPM is supported too. Usage For now, Bindy has a coupl

UIKitPreviews - A simple way to see your UIKit ViewController changes live and on-demand
UIKitPreviews - A simple way to see your UIKit ViewController changes live and on-demand

SwiftUI preview provider for UIKit A simple way to see your UIKit ViewController

A Simple exemple of a launching screen made of 100% using SwuiftUI.
A Simple exemple of a launching screen made of 100% using SwuiftUI.

A Simple exemple of a launching screen made of 100% using SwuiftUI. You can modify and use it in your app Compatible from iOS 14 (older not tested ) to iOS 16 (beta tested only )

Comments
  • dyld: Library not loaded: @rpath/SSPager.framework/SSPager

    dyld: Library not loaded: @rpath/SSPager.framework/SSPager

    동작 상세

    앱 실행과 함께 런타임 오류 발생

    오류 내용

    SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
    dyld: Library not loaded: @rpath/SSPager.framework/SSPager
      Referenced from: /private/var/containers/Bundle/Application/56C45CC8-A8F6-4AD0-8A79-AD66F8A8E8C2/SSPagerExample.app/SSPagerExample
      Reason: image not found
    dyld: launch, loading dependent libraries
    DYLD_LIBRARY_PATH=/usr/lib/system/introspection
    DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
    
    opened by Jino0910 1
Owner
9oya
9oya
RxSwift extension for RealmSwift's types

RxRealm This library is a thin wrapper around RealmSwift ( Realm Docs ). Table of contents: Observing object collections Observing a single object Wri

RxSwift Community 1.1k Jan 6, 2023
STDevRxExt contains some extension functions for RxSwift and RxCocoa which makes our live easy.

STDevRxExt Example To run the Example.playground, clone the repo, and run pod install from the Example directory first. Requirements iOS 9.0+ tvOS 9.0

STDev 6 Mar 26, 2021
A super simple library for state management with unidirectional data flow.

OneWay ?? OneWay is still experimental. As such, expect things to break and change in the coming months. OneWay is a super simple library for state ma

SeungYeop Yeom 41 Dec 20, 2022
RxSwift extentions for Swift optionals and "Occupiable" types

RxOptional RxSwift extentions for Swift optionals and "Occupiable" types. Usage All operators are available on Driver as well unless otherwise marked.

Thane Gill 8 Jun 28, 2020
RxSwift bindings for Permissions API in iOS.

RxPermission RxSwift bindings for Permission API that helps you with Permissions in iOS. Installation RxPermission is available through CocoaPods. I c

Luke 230 Dec 27, 2022
RxSwift wrapper around the elegant HTTP networking in Swift Alamofire

RxAlamofire RxAlamofire is a RxSwift wrapper around the elegant HTTP networking in Swift Alamofire. Getting Started Wrapping RxSwift around Alamofire

RxSwift Community 1.6k Jan 3, 2023
A testable RxSwift wrapper around MultipeerConnectivity

A testable RxSwift wrapper around MultipeerConnectivity RxMultipeer is a RxSwift wrapper for MultipeerConnectivity. Using the adapter pattern, we can

RxSwift Community 69 Jul 5, 2022
iOS & OSX Bluetooth library for RxSwift

RxBluetoothKit is a Bluetooth library that makes interaction with BLE devices much more pleasant. It's backed by RxSwift and CoreBluetooth and it prov

Polidea 1.3k Dec 16, 2022
RxSwift reactive wrapper for view gestures

RxGesture Usage To run the example project, clone the repo, in the Example folder open RxGesture.xcworkspace. You might need to run pod install from t

RxSwift Community 1.3k Dec 30, 2022
Handy RxSwift extensions on NSObject, including rx.disposeBag.

NSObject+Rx If you're using RxSwift, you've probably encountered the following code more than a few times. class MyObject: Whatever { let disposeBag

RxSwift Community 625 Dec 12, 2022