Infinite paging controller, scrolling through contents and title bar scrolls with a delay

Overview

PageController

Build-Status CocoaPods Carthage compatible license

PageController is infinite paging controller, scrolling through contents and title bar scrolls with a delay. Then it provide user interaction to smoothly and effortlessly moving. It is for iOS written in Swift.

sample

Requirements

PageController Xcode Swift
0.7.x + 9.4 4.1
0.6.x 9.2 4.0
0.5.x 8.2 3.0
0.4.x 8.0 2.2
0.3.x 7.0+ 2.0
0.2.0 6.4 1.2

Features

  • To inherit from DCScrollView
  • Use UIViewController, not UIView like UITabBarController
  • Support AutoLayout about MenuCell
  • Handling to change current view controller with Delegate.
  • Scrolling smoothly and effortlessly
  • Keep to smoothly in scrolling contents

Installation

CocoaPods

pod 'PageController'

Carthage

To integrate PageController into your Xcode project using Carthage, specify it in your Cartfile:

github "hirohisa/PageController" ~> 0.7.1

Usage

viewControllers

Type is [UIViewController], and element must have title.

import PageController

class CustomViewController: PageController {

    override func viewDidLoad() {
        super.viewDidLoad()

        viewControllers = createViewControllers()
    }

    func createViewControllers() -> [UIViewController] {
        let names = [
            "favorites",
            "recents",
            "contacts",
            "history",
            "more",
        ]

        return names.map { name -> UIViewController in
            let viewController = ContentViewController()
            viewController.title = name
            return viewController
        }
    }
}

MenuBar

Enable to change backgroundColor, frame. If you change MenuBarCell.height, then override frameForMenuBar and set height.

/// backgroudColor
menuBar.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.9)
/// skip to auto-select after scrolling
menuBar.isAutoSelectDidEndUserInteractionEnabled = false

/// frame, override this function
override var frameForMenuBar: CGRect {
    let frame = super.frameForMenuBar

    return CGRect(x: frame.minX, y: frame.minY, width: frame.width, height: 60)
}

MenuBarCell

Enable to use Custom Cell supported MenuBarCellable protocol:

public protocol MenuBarCellable {
    var index: Int { get set }
    func setTitle(_ title: String)
    func setHighlighted(_ highlighted: Bool)
    func prepareForReuse()
}

public func register(_ cellClass: MenuBarCellable) {
    guard let cellClass = cellClass as? UIView.Type else { fatalError() }
    self.cellClass = cellClass
}

public func register(_ nib: UINib) {
    self.nib = nib
}

MenuBarCellable

public protocol MenuBarCellable {

    // it's used by PageController
    var index: Int { get set }

    // it is used to set to Label.text, caused by deprecating MenuCell over 0.7
    func setTitle(_ title: String)

    // it's instead of `updateData` over 0.7,
    func setHighlighted(_ highlighted: Bool)

    // Called by the menu bar on creating the instance.
    func prepareForUse()

}

License

PageController is available under the MIT license.

Comments
  • Change the timing to call switchVisibleViewController

    Change the timing to call switchVisibleViewController

    I think switchVisibleViewController(visibleViewController) should be called after displayViewController was called.

    It is because delegate method (didChangeVisibleController) is called just after changing visibleViewController.

    When I want to change viewController that I don't want to show, I use the delegate method and change the viewController. But in "func loadPages(AtCenter index: Int)", displayViewController was called after switchVisibleViewController() then re-update viewController, so that I can't change viewController in didChangeVisibleController delegate method.

    Is there any way to change viewController in didChangeVisibleController delegate method?

    opened by kawasin73 5
  • PageController does not work with NavigationBar prefersLargeTitles

    PageController does not work with NavigationBar prefersLargeTitles

    Menu items are hidden behind the navigationBar and navigationBar does not scroll up if navigationBar.prefersLargeTitles is set to true. Tried with the code below at CustomViewController:

    `override func viewDidLoad() { super.viewDidLoad()

        self.title = "Custom"
        if #available(iOS 11.0, *) {
            self.navigationController?.navigationBar.prefersLargeTitles = true
        } else {
            // Fallback on earlier versions
        }
    

    ... }`

    no-issue-activity 
    opened by askarimov 2
  • Change selected item to bold in menu bar

    Change selected item to bold in menu bar

    It would be nice PageController did this automatically, but how would I do it myself. If change the font when an item is selected it truncates the item text and if I try to make it update its layout it does funky this like take up more vertical space temporarily.

    opened by infiniteNIL 1
  • Change the position of MenuBar?

    Change the position of MenuBar?

    The navigationBar of my app will hide when the user scrolls the tableView. But the MenuBar stays where it is. I tried to add top space constraint to the MenuBar so that it can move with the navigationBar, however that didn't help. Any idea?

    opened by TunaYangSkey 1
  • How to lock scroll to first page!

    How to lock scroll to first page!

    Dear Hirohisa! I want to lock scroll to the first page when the (current page == max page) or lock scroll to the last page when the (current page == 0). How can I do that? Thank you very much!

    opened by havudk1707 1
  • Switch scrolling detect level of PagerController.scrollView

    Switch scrolling detect level of PagerController.scrollView

    I want to change viewController after scrolling new page completely.

    To do this action, you should switch PageController.scrollType to .Edge.

    It is first time for me to create pull request to other project. If there is any bad point, please point out! thank you.

    opened by kawasin73 1
Owner
Hirohisa Kawasaki
Hirohisa Kawasaki
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting

Features • Guides • Installation • Usage • Miscellaneous • Contributing ?? README is available in other languages: ???? . ???? . ???? . ???? . ???? To

Juanpe Catalán 11.7k Jan 6, 2023
A controller that uses a UIStackView and view controller composition to display content in a list

StackViewController Overview StackViewController is a Swift framework that simplifies the process of building forms and other static content using UIS

Seed 867 Dec 27, 2022
📖 A lightweight, paging view solution for SwiftUI

Getting Started | Customization | Installation Getting Started Basic usage Using Pages is as easy as: import Pages struct WelcomeView: View { @S

Nacho Navarro 411 Dec 29, 2022
A paging scroll view for SwiftUI, using internal SwiftUI components

PagingView A paging scroll view for SwiftUI, using internal SwiftUI components. This is basically the same as TabView in the paging mode with the inde

Eric Lewis 18 Dec 25, 2022
Paging Library for Infinity Scroll using RxSwift

Paging Library for Infinity Scroll using RxSwift

SubinJang 2 Mar 31, 2022
A library, which adds the ability to hide navigation bar when view controller is pushed via hidesNavigationBarWhenPushed flag

HidesNavigationBarWhenPushed A library, which adds the ability to hide navigation bar when view controller is pushed via hidesNavigationBarWhenPushed

Danil Gontovnik 55 Oct 19, 2022
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically.

Zhouqi Mo 3.3k Dec 21, 2022
Scrollable UINavigationBar that follows the scrolling of a UIScrollView

A custom UINavigationController that enables the scrolling of the navigation bar alongside the scrolling of an observed content view Versioning notes

Andrea Mazzini 6.1k Dec 24, 2022
A container view that responds to scrolling of UIScrollView

FlexibleHeader A container view that responds to scrolling of UIScrollView. normal threshold FlexibleHeaderExecutantType Getting Started Progressive I

DongHee Kang 69 May 2, 2022
A set of UIKit helpers that simplify the usage of UIKit view's and controller's in SwiftUI.

A set of UIKit helpers that simplify the usage of UIKit view's and controller's in SwiftUI. Many of these helpers are useful even in a pure UIKit project.

SwiftUI+ 6 Oct 28, 2022
AGCircularPicker is helpful component for creating a controller aimed to manage any calculated parameter

We are pleased to offer you our new free lightweight plugin named AGCircularPicker. AGCircularPicker is helpful for creating a controller aimed to man

Agilie Team 617 Dec 19, 2022
A child view controller framework that makes setting up your parent controllers as easy as pie.

Description Family is a child view controller framework that makes setting up your parent controllers as easy as pie. With a simple yet powerful publi

Christoffer Winterkvist 246 Dec 28, 2022
Highly customizable Action Sheet Controller with Assets Preview written in Swift

PPAssetsActionController Play with me ▶️ ?? If you want to play with me, just tap here and enjoy! ?? ?? Show me ?? Try me ?? The easiest way to try me

Pavel Pantus 72 Feb 4, 2022
Reel Search is a Swift UI controller that allows you to choose options from a list

REEL SEARCH Reel Search is a Swift UI controller that allows you to choose options from a list We specialize in the designing and coding of custom UI

Ramotion 2.5k Dec 21, 2022
A SwiftUI bottom-up controller, like in the Maps app. Drag to expand or minimize.

SwiftUI Drawer A SwiftUI bottom-up controller, like in the Maps app. Drag to expand or minimize. Contents Add the Package Basic Usage Examples Credits

Michael Verges 695 Jan 3, 2023
Page view controller with bounce effect

BouncyPageViewController Page view controller with bounce effect inspired by motion design by Stan Yakushevish. Quickstart Create a queue of UIViewCon

Bohdan Orlov 843 Oct 17, 2022
iOS custom controller used in Jobandtalent app to present new view controllers as cards

CardStackController iOS custom controller used in the Jobandtalent app to present new view controllers as cards. This controller behaves very similar

jobandtalent 527 Dec 15, 2022
ElongationPreview is an elegant UI push-pop style view controller

ElongationPreview is an elegant UI push-pop style view controller

Ramotion 886 Dec 19, 2022