Latest 0.2.0
Homepage https://github.com/shawnbaek/Slippery
License MIT
Platforms ios 11.0
Authors

CI Status
Version
License
Platform

Example

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

Requirements

Swift 4.0
iOS 11.0

Installation

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

pod 'Slippery'

Storyboard

Guide

Drag UICollectionViewController or UICollectionView in UIViewController

Set CollectionViewFlowLayout as SlipperyFlowLayout

That’s It

Center Mode

Center Mode has two options.

  1. cropping

Guide

cropping mode is cropping the first and last cell


highlightOption: .center(.cropping)
  1. normal

Guide

first and the last cell is always positioning at center.


highlightOption: .center(.normal)

Custom Mode

You can set specifit focused position from leading to first, second, third, fourth and fifth

highlightOption: .custom(.leading, .third)

Check Example of SliceVC

Scale and Opacity Options

You can fully customizing focusing options.

self.collectionViewLayout.minimumOpacityFactor = 0.1
self.collectionViewLayout.minimumScaleFactor = 1.0

e.g. minimumScaleFactor = 1.0 means disable the scale mode
e.g. minimumScaleFactor = 0.4 means set other cells scale as 0.4

Sample Project

Calendar View


func setupCollectionView(){

    self.collectionViewLayout = SlipperyFlowLayout.configureLayout(collectionView: self.calendarView, itemSize: CGSize(width: 120, height: 180), minimumLineSpacing: 10, highlightOption: .center(.cropping))
    self.collectionViewLayout.scaleItems = true
    self.collectionViewLayout.invalidateLayout()
    self.calendarView.layoutIfNeeded()

}

SliceNumver View


func setupCollectionView(){

    self.collectionViewLayout = SlipperyFlowLayout.configureLayout(collectionView: self.sliceView, itemSize: CGSize(width: 30, height: 180), minimumLineSpacing: 20, highlightOption: .custom(.leading, .third))

    self.collectionViewLayout.invalidateLayout()
    self.sliceView.layoutIfNeeded()

}

Photo View

func setupCollectionView(){

    self.collectionViewLayout = SlipperyFlowLayout.configureLayout(collectionView: self.photoView, itemSize: CGSize(width: 150, height: 180), minimumLineSpacing: 20, highlightOption: .center(.normal))

    self.collectionViewLayout.invalidateLayout()
    self.photoView.layoutIfNeeded()

}

scrollToItem

create a scrollToItem function in your ViewController

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

    setupCollectionView()
    scrollToItem(item: 20, animated: true)
}

func createDummyNumbers(){

    for i in 0 ... 100 {
    dummyNumbers.append(i)
    }
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.view.layoutIfNeeded()
}

func scrollToItem(item: Int, animated: Bool) {

    let itemOffset = self.collectionViewLayout.updateOffset(item: item)
    self.calendarView.setContentOffset(CGPoint(x: itemOffset, y: 0), animated: true)
    self.calendarView.layoutIfNeeded()

}

Acknowledgment

I make this Library inspired by LGLinearFlow.
Thank you for sharing your code.

Author

shawnbaek, [email protected]

Contact

I want to connect developers who loves iOS development. Follow me and Let’s keep in touch. I want to make a friends! :smaile:
twitter

License

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

Latest podspec

{
    "name": "Slippery",
    "version": "0.2.0",
    "summary": "Slippery is UICollectionViewFlowlayout to highlight the cell.",
    "description": "TODO: Easy to customize your CollectionView styles and user-facing swipe interaction.",
    "homepage": "https://github.com/shawnbaek/Slippery",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "shawnbaek": "[email protected]"
    },
    "source": {
        "git": "https://github.com/shawnbaek/Slippery.git",
        "tag": "0.2.0"
    },
    "platforms": {
        "ios": "11.0"
    },
    "swift_version": "4.0",
    "source_files": "Slippery/Classes/SlipperyFlowLayout.swift"
}

Pin It on Pinterest

Share This