Git Product home page Git Product logo

parchment's Introduction

Getting Started | Customization | Installation


Cities Example Unsplash Example Calendar Example

Features

Parchment lets you page between view controllers while showing any type of generic indicator that scrolls along with the content. Here are some benefits of using Parchment:

  • Highly customizable
    The menu items are built using UICollectionView, which means you can display pretty much whatever you want. You can even subclass the layout to create completely custom behaviours.

  • Memory-efficient:
    Parchment only allocates view controllers when they’re needed, meaning if you have a lot of view controllers you don’t have to initialize them all up-front.

  • Infinite scrolling:
    Because view controllers are only allocated as you are scrolling, you can create data sources that are infinitely large. This is perfect for things like calendars.

Table of contents

Getting started

Using UIKit? Go to UIKit documentation.

SwiftUI

Basic usage

Create a PageView instance with the pages you want to show. Each Page takes a title and a content view, which can be any SwiftUI view.

PageView {
    Page("Title 0") {
        Text("Page 0")
    }
    Page("Title 1") {
        Text("Page 1")
    }
}

By default, the menu items are displayed as titles, but you can also pass in any SwiftUI view as the menu item. The state parameter allows you to customize the menu item based on the selected state and scroll position of the view. For instance, you could show an icon that rotates based on its progress like this:

PageView {
    Page { state in
        Image(systemName: "star.fill")
            .rotationEffect(Angle(degrees: 90 * state.progress))
    } content: {
        Text("Page 1")
    }
}

Dynamic pages

To create a PageView with a dynamic number of pages, you can pass in a collection of items where each item is mapped to a Page:

PageView(items, id: \.self) { item in
    Page("Title \(item)") {
        Text("Page \(item)")
    }
}

Update selection

To select specific items, you can pass a binding into PageView with the index of the currently selected item. When updating the binding, Parchment will scroll to the new index.

@State var selectedIndex: Int = 0
...
PageView(selectedIndex: $selectedIndex) {
    Page("Title 1") {
        Button("Next") {
            selectedIndex = 1
        }
    }
    Page("Title 2") {
        Text("Page 2")
    }
}

Modifiers

You can customize the PageView using the following modifiers. See Options for more details on each option.

PageView {
    Page("Title 1") {
        Text("Page 1")
    }
}
.menuItemSize(.fixed(width: 100, height: 60))
.menuItemSpacing(20)
.menuItemLabelSpacing(30)
.menuBackgroundColor(.white)
.menuInsets(.vertical, 20)
.menuHorizontalAlignment(.center)
.menuPosition(.bottom)
.menuTransition(.scrollAlongside)
.menuInteraction(.swipe)
.contentInteraction(.scrolling)
.contentNavigationOrientation(.vertical)
.selectedScrollPosition(.preferCentered)
.indicatorOptions(.visible(height: 4))
.indicatorColor(.blue)
.borderOptions(.visible(height: 4))
.borderColor(.blue.opacity(0.2))
UIKit

Basic usage with UIKit

Parchment is built around the PagingViewController class. You can initialize it with an array of view controllers and it will display menu items for each view controller using their title property.

let firstViewController = UIViewController()
let secondViewController = UIViewController()

let pagingViewController = PagingViewController(viewControllers: [
  firstViewController,
  secondViewController
])

See more: Basic usage

Data source

Initializing PagingViewController with an array of view controllers is fine in most cases, but if you have more than a few view controllers you probably don't want to allocate them all up-front. If you're going to display a fixed number of view controllers, you can setup your own data source by implementing PagingViewControllerDataSource:

extension ViewController: PagingViewControllerDataSource {
    func numberOfViewControllers(in pagingViewController: PagingViewController) -> Int {
        return 10
    }

    func pagingViewController(_ pagingViewController: PagingViewController, viewControllerAt index: Int) -> UIViewController {
        return ChildViewController(index: index)
    }

    func pagingViewController(_: PagingViewController, pagingItemAt index: Int) -> PagingItem {
        return PagingIndexItem(title: "View \(index)", index: index)
    }
}

Then you need to set the dataSource property and select the initial item:

let pagingViewController = PagingViewController()
pagingViewController.dataSource = self
pagingViewController.select(index: 0)

Using the data source means Parchment will only allocate view controllers for the currently selected item and any of its siblings. This is a lot more memory efficient than using PagingViewController(viewControllers:) if you have many view controllers.

Read more: Using the data source

Infinite data source

Using PagingViewControllerDataSource means you need to know how many view controllers to display. If you’re creating something like a calendar, the number of view controllers can be infinitely large. In that case you can use the PagingViewControllerInfiniteDataSource protocol:

extension ViewController: PagingViewControllerInfiniteDataSource {
    func pagingViewController(_: PagingViewController, viewControllerFor pagingItem: PagingItem) -> UIViewController {
        return ItemViewController(item: pagingItem)
    }

    func pagingViewController(_: PagingViewController, itemBefore pagingItem: PagingItem) -> PagingItem? {
        guard let item = pagingItem as? Item else { return nil }
        return Item(index: item.index - 1)
    }

    func pagingViewController(_ : PagingViewController, itemAfter pagingItem: PagingItem) -> PagingItem? {
        guard let item = pagingItem as? Item else { return nil }
        return Item(index: item.index + 1)
    }
}

Then set the infiniteDataSource property and select the initial item:

let pagingViewController = PagingViewController()
pagingViewController.infiniteDataSource = self
pagingViewController.select(pagingItem: Item(index: 0))

This pattern is very similar to the UIPageViewControllerDataSource protocol. The main difference is that instead of returning view controllers directly, you have to return an instance conforming to the PagingItem protocol. Parchment will recursively call these methods for the selected PagingItem until the available space is filled up.

Read more: Using the infinite data source

Selecting items

You can select items programatically using:

func select(pagingItem: PagingItem, animated: Bool = false)

Let’s say you want to select the first item:

override func viewDidLoad() {
  super.viewDidLoad()
  if let first = pagingViewController.children.first as? PagingItem {
    pagingViewController.select(pagingItem: first)
  }
}

Or if you have set the dateSource property, you can select items based on their index:

func select(index: Int, animated: Bool = false)

Reloading data

You can reload data using this method:

func reloadData()

This will keep the previously selected item if it's still part of the updated data. If not, it will select the first item in the list. It will also reload the view controllers displayed in the page view controller. If you only want to reload the menu items, you can use this method:

func reloadMenu()

Calling reloadData() will not work when using PagingViewControllerInfiniteDataSource, as we then need to know what the initial item should be. In that case you should use this method:

func reloadData(around: PagingItem)

This will mark the given paging item as selected and generate new items around it.

Delegate

Parchment provides delegate methods for every step of the transition process through the PagingViewControllerDelegate protocol.

protocol PagingViewControllerDelegate: class {

    func pagingViewController(
        _: PagingViewController,
        isScrollingFromItem currentPagingItem: PagingItem,
        toItem upcomingPagingItem: PagingItem?,
        startingViewController: UIViewController,
        destinationViewController: UIViewController?,
        progress: CGFloat)

    func pagingViewController(
        _: PagingViewController,
        willScrollToItem pagingItem: PagingItem,
        startingViewController: UIViewController,
        destinationViewController: UIViewController)

    func pagingViewController(
        _ pagingViewController: PagingViewController,
        didScrollToItem pagingItem: PagingItem,
        startingViewController: UIViewController?,
        destinationViewController: UIViewController,
        transitionSuccessful: Bool)

    func pagingViewController(
        _ pagingViewController: PagingViewController,
        didSelectItem pagingItem: PagingItem)
}

Size delegate

By default, the size of the menu items is controlled by the menuItemSize property. If you need to control width of each menu item individually you can use the PagingControllerSizeDelegate protocol:

protocol PagingViewControllerSizeDelegate: class {
    func pagingViewController(
        _: PagingViewController,
        widthForPagingItem pagingItem: PagingItem,
        isSelected: Bool) -> CGFloat
}

Then set the sizeDelegate on the PagingViewController:

let pagingViewController = PagingViewController()
pagingViewController.sizeDelegate = self

Customization

Parchment is built to be very flexible. The menu items are displayed using UICollectionView, so they can display pretty much whatever you want. If you need any further customization you can even subclass the collection view layout. All customization is handled by the properties listed below.

Custom cells

To use custom cells you need to subclass PagingCell and register the cell type for a given PagingItem:

let pagingViewController = PagingViewController()
pagingViewController.register(CalendarPagingCell.self, for: CalendarItem.self)

Parchment will then dequeue your custom cell when you return the given PagingItem in your data source. You can register multiple cell types for different PagingItems.

Properties

All customization properties are set on PagingViewController:

let pagingViewController = PagingViewController()
pagingViewController.menuItemSize = .fixed(width: 40, height: 40)
pagingViewController.menuItemSpacing = 10

See Options for all customization options.

Options

menuItemSize

The size of the menu items. When using sizeDelegate the width will be ignored.

enum PagingMenuItemSize {
  case fixed(width: CGFloat, height: CGFloat)

  // Automatically calculate the size of the menu items based on the
  // cells intrinsic content size. Try to come up with an estimated
  // width that's similar to the expected width of the cells.
  case selfSizing(estimatedWidth: CGFloat, height: CGFloat)

  // Tries to fit all menu items inside the bounds of the screen.
  // If the items can't fit, the items will scroll as normal and
  // set the menu items width to `minWidth`.
  case sizeToFit(minWidth: CGFloat, height: CGFloat)
}

Default: .sizeToFit(minWidth: 150, height: 40)

menuItemSpacing

The spacing between the menu items.

Default: 0

menuItemLabelSpacing

The horizontal constraints of menu item label.

Default: 20

menuInsets

The insets around all of the menu items.

Default: UIEdgeInsets()

menuHorizontalAlignment

enum PagingMenuHorizontalAlignment {
  case `default`

  // Allows all paging items to be centered within the paging menu
  // when PagingMenuItemSize is .fixed and the sum of the widths
  // of all the paging items are less than the paging menu
  case center
}

Default: .default

menuTransition

Determine the transition behaviour of menu items while scrolling the content.

enum PagingMenuTransition {
  // Update scroll offset based on how much the content has
  // scrolled. Makes the menu items transition smoothly as you scroll.
  case scrollAlongside

  // Animate the menu item position after a transition has completed.
  case animateAfter
}

Default: .scrollAlongside

menuInteraction

Determine how users can interact with the menu items.

enum PagingMenuInteraction {
  case scrolling
  case swipe
  case none
}

Default: .scrolling

menuLayoutClass

The class type for collection view layout. Override this if you want to use your own subclass of the layout. Setting this property will initialize the new layout type and update the collection view.

Default: PagingCollectionViewLayout.Type

selectedScrollPosition

Determine how the selected menu item should be aligned when it is selected. Effectively the same as the UICollectionViewScrollPosition.

enum PagingSelectedScrollPosition {
  case left
  case right

  // Centers the selected menu item where possible. If the item is
  // to the far left or right, it will not update the scroll position.
  // Effectivly the same as .centeredHorizontally on UIScrollView.
  case preferCentered
}

Default: .preferCentered

indicatorOptions

Add an indicator view to the selected menu item. The indicator width will be equal to the selected menu items width. Insets only apply horizontally.

enum PagingIndicatorOptions {
  case hidden
  case visible(
    height: CGFloat,
    zIndex: Int,
    spacing: UIEdgeInsets,
    insets: UIEdgeInsets)
}

Default:

.visible(
  height: 4,
  zIndex: Int.max,
  spacing: UIEdgeInsets.zero,
  insets: UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8))

indicatorClass

The class type for the indicator view. Override this if you want your use your own subclass of PagingIndicatorView.

Default: PagingIndicatorView.self

indicatorColor

The background color for the indicator view.

Default: UIColor(red: 3/255, green: 125/255, blue: 233/255, alpha: 1)

borderOptions

Add a border at the bottom of the menu items. The border will be as wide as all the menu items. Insets only apply horizontally.

enum PagingBorderOptions {
  case hidden
  case visible(
    height: CGFloat,
    zIndex: Int,
    insets: UIEdgeInsets)
}

Default:

.visible(
  height: 1,
  zIndex: Int.max - 1,
  insets: UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8))

borderClass

The class type for the border view. Override this if you want your use your own subclass of PagingBorderView.

Default: PagingBorderView.self

borderColor

The background color for the border view.

Default: UIColor(white: 0.9, alpha: 1)

includeSafeAreaInsets

Updates the content inset for the menu items based on the .safeAreaInsets property.

Default: true

font

The font used for title label on the menu items.

Default: UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.medium)

selectedFont

The font used for title label on the currently selected menu item.

Default: UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.medium)

textColor

The color of the title label on the menu items.

Default: UIColor.black

selectedTextColor

The text color for the currently selected menu item.

Default: UIColor(red: 3/255, green: 125/255, blue: 233/255, alpha: 1)

backgroundColor

The background color for the menu items.

Default: UIColor.white

selectedBackgroundColor

The background color for the selected menu item.

Default: UIColor.clear

menuBackgroundColor

The background color for the view behind the menu items.

Default: UIColor.white

Installation

Parchment will be compatible with the lastest public release of Swift.

Requirements

  • iOS 12.0+
  • Xcode 14.0+

CocoaPods

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

pod 'Parchment', '~> 4.0'

Swift Package Manager

Parchment is available through Swift Package Manager. Add Parchment as a dependency to your Package.swift:

.package(url: "https://github.com/rechsteiner/Parchment", from: "4.0.0")

Carthage

Parchment also supports Carthage. To install it, add the following to your Cartfile:

github "rechsteiner/Parchment" ~> 4.0

See this guide for more details on using Carthage.

Changelog

This can be found in the CHANGELOG file.

Licence

Parchment is released under the MIT license. See LICENSE for details.

parchment's People

Contributors

ageevvalentin avatar aikrice avatar alexjameslittle avatar ayastrebov avatar cetineremre avatar cheebow avatar econa77 avatar hugehoge avatar ianhoar avatar ikesyo avatar ispiropoulos avatar kitwtnb avatar linizio avatar mimo42 avatar mironal avatar motasay avatar naruu avatar nfgrilo avatar pangmo5 avatar pot8os avatar realbonus avatar rechsteiner avatar rocxteady avatar rono23 avatar ryoabe avatar simorgh3196 avatar sugitatestblue avatar tbaranes avatar voyager163 avatar yosshi4486 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parchment's Issues

Allow scrolling in the menu items header

Currently, the menu items only have a swipe gesture to switch between pages. It would be nice to be able to scroll freely inside the menu items collection view.

UIFont has no member weight

screen shot 2017-09-28 at 8 01 14 pm

It is strange because it still exists in the UIKit documentation. I've tried using it in Playground but it refuses to work.

willScrollToItem delegate method is not getting called.

open class PagingViewController<T: PagingItem>:

is not declaring the optional function

    @objc  optional func em_pageViewController(_ pageViewController: EMPageViewController, willStartScrollingFrom startingViewController: UIViewController, destinationViewController:UIViewController)

Which require overriding the function in FixedPagingViewController:

open override func em_pageViewController(_ pageViewController: EMPageViewController, didFinishScrollingFrom startingViewController: UIViewController?, destinationViewController: UIViewController, transitionSuccessful: Bool) `

only then will the delegate method willScrollToItem be called.

Loading Current Controller not updating

I am using the following code to try and select a view controller - but its data structure is empty in

    let controllers = viewcontrollers(from: pagingItems)
    pagingViewController =  FixedPagingViewController(viewControllers: controllers, options:    CustomOptions())
   addChildViewController(pagingViewController!)
    viewHolder.addSubview((pagingViewController?.view)!)
    viewHolder.constrainToEdges((pagingViewController?.view)!)
   
    
    // Set our custom data source
    pagingViewController!.itemDelegate = self
    
    // Set the current date as the selected paging item
     let items = pagingViewController.items 
        let index = Defaults[.vcIndex]
        if index < items.count {
            pagingViewController!.selectPagingItem(pagingViewController.items [index])
        }
     pagingViewController?.didMove(toParentViewController: self)

In PagingViewController.swift, dataStructure is empty.

     open func selectPagingItem(_ pagingItem: T, animated: Bool = false) { 
       if let stateMachine = stateMachine {
      if let indexPath = dataStructure.indexPathForPagingItem(pagingItem) {
        let direction = dataStructure.directionForIndexPath(indexPath, currentPagingItem: pagingItem)
        stateMachine.fire(.select(
          pagingItem: pagingItem,
          direction: direction,
          animated: animated))
      }

Not possible to have transparent/ translucent nav. bar

Hello!

We tried but didn't succeed in making the effect when what is vertically scrolled in the view appears underneath the nav. bar in order to have transparency/translucency effect.

Our idea was to make

  1. Fully transparent nav. bar
  2. Make fully transparent menu (horizontal collection view with icons).
  3. Than add custom view (nav. bar view) of a certain height and level of translucency.
    We, actually, succeeded in all of that. The bottleneck appeared to be that we couldn't move the view underneath the nav. bar and the menu itself. We also don't really understand how to change y position of the menu (horizontal collection view with icons), neither of the view, independently of each other.

By view here I mean the any view (tableview, collectionView, ...) that is inserter into the contentView together with the menu (horizontal collection view with icons).

I tried to explain on this picture.
So we need to put the view underneath the nav. bar and the menu. And move it up to the contentView's top margin.

screen shot 2017-02-02 at 19 59 36

Memory leak

If you build Parchment (r.0.5.0) with the "leak checker" tool, you can see a memory leak, if I'm not mistaken, the method is:

override open func layoutAttributesForElements (in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {}

screenshot at sep 26 15-13-36

I may be wrong, but I think the problem is to use self when initializing an array.

screenshot at sep 26 15-21-03

One solution would be to use unowned self as follows.

  lazy var layoutAttributesValues: [UICollectionViewLayoutAttributes] = { [unowned self] in
        return Array(self.layoutAttributes.values)
  }()
    
  override open func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {

    var layoutAttributes: [UICollectionViewLayoutAttributes] = layoutAttributesValues
    
    for attributes in layoutAttributes {
      if let pagingAttributes = attributes as? PagingCellLayoutAttributes {
        pagingAttributes.progress = progressForItem(at: attributes.indexPath)
      }
    }
    
    let indicatorAttributes = layoutAttributesForDecorationView(
      ofKind: PagingIndicatorView.reuseIdentifier,
      at: IndexPath(item: 0, section: 0))
    
    let borderAttributes = layoutAttributesForDecorationView(
      ofKind: PagingBorderView.reuseIdentifier,
      at: IndexPath(item: 1, section: 0))
    
    if let indicatorAttributes = indicatorAttributes {
      layoutAttributes.append(indicatorAttributes)
    }
    
    if let borderAttributes = borderAttributes {
      layoutAttributes.append(borderAttributes)
    }
    
    return layoutAttributes
  }

"I will be grateful to you ... if you correct this issue as soon as possible.
Thank you

Highlighting when scrolling between items

Some strange highlighting in previous and current item when scrolling?
How to remove that ?
Impementation

        let vc = FixedPagingViewController(viewControllers: controllers)
        vc.font = QTFont.with(14)
        vc.backgroundColor = QTColor.darkTurquoise.withNightMode()
        vc.indicatorColor = QTColor.sunYellow
        vc.selectedTextColor = QTColor.sunYellow
        vc.textColor = .white
        vc.selectedBackgroundColor = .clear
        vc.menuBackgroundColor = .clear
        vc.delegate = self
        return vc

Background color

i want the background color to change based on which item is selected

Menu on navigationbar

Hi,i want to add menu on navigationbar , how to work it out.
Or Parchment can't do it like that?
I'll be waiting for your reply.

Add progress value to menu items

Right now the menu items are only updated after a transition has completed. Adding a progress on the PagingCell based on how much the content is scrolled would allow us to smoothly transition between size/color etc.

buggy scrolling in pageViewController on iOS 11 / iPhone X

There is a buggy scrolling in pageViewController on iOS 11 / iPhone X. It scrolls in all directions.
Don't know why but this bug is present on all our devices with our project, and only on iPhone X with your example (icon Example)

simulator screen shot - iphone x - 2017-11-08 at 02 52 34

Apparently, it's linked to this scrollview and to scrollview insets.

screenshot at nov 08 02-53-01

In our project, actually by guess, I have solved this problem with this code, though I am not sure if that's the best solution.

scrollView.contentInsetAdjustmentBehavior = .never

How to programmatically select item?

Take the storyboard example project, if I want to programmatically select the secondVC, how do I do it?

If I do:
pagingViewController.select(index: 1)

When I run the app, secondVC isn't shown and the top menu still shows the first one and can't navigate anymore. What am I missing?

Sorry if this is a stupid question, I just can't figure it out!

FixedPagingViewControllerDelegate does not recognize an aborted scroll

Currently FixedPagingViewControllerDelegate does not recognize an aborted scroll. Running the code as noted below increments the index even when a scroll is not completed.

extension UIViewController: FixedPagingViewControllerDelegate{
func fixedPagingViewController(fixedPagingViewController: FixedPagingViewController, willScrollToItem: ViewControllerItem, atIndex index: Int) {
    print("about to move to: \(index)")
}

func fixedPagingViewController(fixedPagingViewController: FixedPagingViewController, didScrollToItem: ViewControllerItem, atIndex index: Int) {
     Defaults[.vcIndex] = index
    print("Moved to: \(index)")
}

}

Suggest something similar to the following changes to FixedPagingViewController that sends destination index only on successful transition

` // MARK: EMPageViewControllerDelegate

open override func em_pageViewController(_ pageViewController: EMPageViewController, didFinishScrollingFrom startingViewController: UIViewController?, destinationViewController: UIViewController, transitionSuccessful: Bool) {
    super.em_pageViewController(pageViewController, didFinishScrollingFrom: startingViewController, destinationViewController: destinationViewController, transitionSuccessful: transitionSuccessful)
    
    if let index = items.index(where: { $0.viewController == destinationViewController }) {
        if let cIndex = currentIndex {
            itemDelegate?.fixedPagingViewController(
                fixedPagingViewController: self,
                didScrollToItem: items[index],
                atIndex: transitionSuccessful ? index  : cIndex )
        }
    }
}

public override func em_pageViewController(_ pageViewController: EMPageViewController, willStartScrollingFrom startingViewController: UIViewController, destinationViewController: UIViewController) {
    if let cIndex = items.index(where: { $0.viewController == startingViewController }) {
        currentIndex = cIndex
    }
    if let index = items.index(where: { $0.viewController == destinationViewController }) {
        itemDelegate?.fixedPagingViewController(
            fixedPagingViewController: self,
            willScrollToItem: items[index],
            atIndex: index)
    }
}`

Swipe in last item bug

Hi :),
i think i found a bug, example: if u are in the last menu item on the left or right and swipe to left or right, after swipe u cant select menu items

Parchment does not work with navigation bars

I'm sorry to bother you yet again but I found this problem.
I had a viewcontroller embed in a uinavigationcontroller and in a uitabbarcontroller.

I compiled the example project you listed and it worked. Then I embed it within a navigation bar but it becomes hidden under the bar. I'm confused because your examples render it correctly.

screen shot 2017-09-29 at 5 21 25 pm

Also, constrain to edges doesn't work in Swift 4.

Autolayout issue

I tried to use this library explained in the onboarding page but it gives me a auto-layout warning:

`[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x608000285f00 V:|-(0)-[UICollectionView:0x7f803388e800] (active, names: '|':Parchment.PagingView:0x7f8032d46f50 )>",
"<NSLayoutConstraint:0x608000286090 UICollectionView:0x7f803388e800.height == 40 (active)>",
"<NSLayoutConstraint:0x608000285690 V:[UICollectionView:0x7f803388e800]-(0)-[UIView:0x7f8032d41970] (active)>",
"<NSLayoutConstraint:0x608000282440 V:[UIView:0x7f8032d41970]-(0)-| (active, names: '|':Parchment.PagingView:0x7f8032d46f50 )>",
"<NSLayoutConstraint:0x600000292ac0 'UIView-Encapsulated-Layout-Height' Parchment.PagingView:0x7f8032d46f50.height == 0 (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x608000285690 V:[UICollectionView:0x7f803388e800]-(0)-[UIView:0x7f8032d41970] (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.`

Swift Compiler Error - Installing via Cocoapods

Hello.

I just installed this module via Cocoapods and keep getting No such module 'Parchment' error, when importing in my ViewController.

I also get 4 errors within the Parchment lib itself:

screen shot 2018-01-29 at 10 59 54 am

I haven't made any changes to the files. I've cleaned out and reinstalled my pods as well. Willing to try out the carthage install too, but figured I should file an issue ticket.

I'm using xcode 9.2 and swift 4.

Thanks for this project and your support!

[Question]

Hi, is possible remove click on menu item?

deinit() of ViewControllers inside FixedPagingViewController is never called

Hello, thanks for creating an awesome library!

In my app, I have a ViewController (let's call: A) that contains FixedPagingViewController that is initialized with 2 viewcontrollers (X & Y). As I just tested, when A is popped off, the function deinit() in X & Y is not called at all. I think if it might lead to a leak memory issue.

Doesn't compile because of inner library error

Added via cocoapods
Version: 0.9.x and 1.0.3
.../Pods/Parchment/Parchment/Classes/PagingOptions.swift:76:50: Type 'UIFont' has no member 'Weight'

In the same time on another pc downloaded this repo and ran examples - they work

Scroll menu items alongside content

The position of menu items are only updated after a transition has completed. Updating the scroll offset based on how much the content is scrolled would make the transition much smoother. We could still keep the current behaviour as an option.

Reload Cell in Collectionview

hi, i have a problem with lib, please help me, how to reload collectionView in pagingView? i try call pagingViewController.collectionView.reloadData() but not work.

Swift 4 migration

Hello Martin,

Any plans for swift 4.
Even though Swift 3.x and Swift 4 are interchangeable, it would be great if there were a Swift 4 version!

Thank you! 😄

Is it possible to change access for the method

Is it possible to do an open method:
 
public func em_pageViewController (_ pageViewController: EMPageViewController, willStartScrollingFrom startingViewController: UIViewController, destinationViewController: UIViewController) {}

I would like to use his heirs class PaguingViivcontroller.

Many thanks.

Load controllers from storyboard

Hi,

Is it possible for loading view controllers from the storyboard rather? i.e., each tab would be a viewcontroller from the storyboard. If so, can you provide an example?

Thanks,
Karthik

min iOS version

I was wondering, why does this pod min iOS version is 8.2? I think 8.0 should be fine.
If it is possible, to have the min iOS version set to 8.0 please?

Different width for a selected cell

Do you think it's possible to have different width for a selected cell?

And update it (width) dynamically (with animation) moving from current to the next cell.

Paging menu items are not centered initially

I initialized a FixedPagingViewController with two controllers, both with icons. I setup everything inside of viewDidLoad but then I noticed that they are not centered correctly. They only are properly centered after clicking on the other icon or swiping to the other tab. Is this possible a bug? or am I just using it incorrectly

How it looks Initially
screen shot 2017-09-26 at 4 48 36 pm

After switching to another tab
screen shot 2017-09-26 at 4 48 43 pm

Now you can see it is properly centered
screen shot 2017-09-26 at 4 53 13 pm

Thanks!

Scrolling bug in the pagingViewController (IconsExample) when applying different width for selected cell in IconsExample

Hey,

I have tried to set up different width for selected cell in IconsExample, wIth selected 60pt and not selected 80pt.

When I slide from controller to controller, relatively fast, pagingViewController on the top occasionally jumps from icon to icon without scrolling animation.

I have added

this

extension ViewController: PagingViewControllerDelegate {
    
    func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, widthForPagingItem pagingItem: T, isSelected: Bool) -> CGFloat {
        
        if isSelected {
            return 80
        } else {
            return 40
        }
    }
    
}

and this

  override func viewDidLoad() {
    ...
    pagingViewController.delegate = self
  }

to the IconsExample ViewController. Did I miss anything? Was that correct?

NavigationBarExample doesn't work

Two errors in the example project for NavigationBar:

  1. Initializer for conditional binding must have Optional type, not 'UIView'
    and
  2. Cannot convert value of type 'Paging Options' to expected argument type 'NSCoder'

Controller menu missing with different initial screen

Hi,

In the Delegate Example (cities), I've added in a new controller (HomeViewController) as the initial view controller. From which, I need to navigate to the cities controller (ViewController). Layout as in screen shot

ss

When I wire the "Go to cities" button to the cities controller (ViewController) or to the navigation controller attached to it, the top city selection menu bar (in cities controller) goes missing. But, the left/right swipe works taking to the new city. How do I fix this?

Thanks

Add custom page view implementation

We're currently using EMPageViewController as a replacement for UIPageViewController, as it’s more predictable and provides us with much better delegate methods at every step.

Ideally, we would replace this library with our own custom implementation to have even more fined grained control. This would also fix an issue with EMPageViewController where it occasionally won’t do anything when swiping rapidly between many pages (#26).

Error

why i got this error ?

ld: warning: ignoring file /Users/bozo/Desktop/*****/Parchment.framework/Parchment, file was built for x86_64 which is not the architecture being linked (arm64): /Users/bozo/Desktop/*****/Parchment.framework/Parchment ld: '/Users/bozo/Library/Developer/Xcode/DerivedData/*****-dhuanbzszeeilpdafoqmheorglne/Build/Products/Debug-iphoneos/Nimble/Nimble.framework/Nimble' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Users/bozo/Library/Developer/Xcode/DerivedData/******-dhuanbzszeeilpdafoqmheorglne/Build/Products/Debug-iphoneos/Nimble/Nimble.framework/Nimble' for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Delegate not working in infinite case

Hi, i just tried to use self size logic in calendar example, I mean use approach in delegate example to have cell size fit to text, but my delegate functions dont fire.
Is it possible to have self size cells for infinite usage?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.