项目作者: Ramotion

项目描述 :
:octocat: Gliding Collection is a smooth, flowing, customizable decision for a UICollectionView Swift Controller. iOS library made by @Ramotion
高级语言: Swift
项目地址: git://github.com/Ramotion/gliding-collection.git
创建时间: 2017-03-03T13:47:23Z
项目社区:https://github.com/Ramotion/gliding-collection

开源协议:MIT License

下载



GLIDING COLLECTION

A smooth, flowing, customizable decision for a UICollectionView Swift Controller


We specialize in the designing and coding of custom UI for Mobile Apps and Websites.




Stay tuned for the latest updates:



Twitter
PodPlatform
PodVersion
Documentation
Carthage
Codebeat
Swift
Donate

Requirements

  • iOS 8.0+
  • Xcode 8
  • Swift 3 (<= 1.0.3)
  • Swift 4 (>= 1.1.0)
  • Swift 4.2 (~> 2.0)


Installation

You can install GlidingCollection in several ways:

  • Add source files to your project.



  • Use Carthage:
    1. github "Ramotion/gliding-collection"


How to use

• Create a view controller class:

  1. import GlidingCollection
  2. class ViewController: UIViewController {
  3. let items = ["gloves", "boots", "bindings", "hoodie"]
  4. }

• Drag a UIView onto the canvas. Change it’s class to GlidingCollection and use autolayout constraints.

step-2

• Connect this view to your view controller class as an @IBOutlet.

  1. @IBOutlet var glidingCollection: GlidingCollection!

• Make your view controller conform to GlidingCollectionDatasource. It’s very similar to the UITableView or UICollectionView datasource protocols that you know:

  1. extension ViewController: GlidingCollectionDatasource {
  2. func numberOfItems(in collection: GlidingCollection) -> Int {
  3. return items.count
  4. }
  5. func glidingCollection(_ collection: GlidingCollection, itemAtIndex index: Int) -> String {
  6. return "– " + items[index]
  7. }
  8. }

• Make your view controller conform to UICollectionViewDatasource:

  1. extension ViewController: UICollectionViewDatasource {
  2. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  3. let section = glidingView.expandedItemIndex // Value of expanded section.
  4. return images[section].count
  5. }
  6. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  7. guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as? CollectionCell else { return UICollectionViewCell() }
  8. // Configure and return your cell.
  9. return cell
  10. }
  11. }

Customize

You can customize the appearance of GlidingCollection by overriding GlidingConfig‘s shared instance with your own.

  1. var config = GlidingConfig.shared
  2. config.buttonsFont = UIFont.boldSystemFont(ofSize: 22)
  3. config.activeButtonColor = .black
  4. config.inactiveButtonsColor = .lightGray
  5. GlidingConfig.shared = config

🗒 All parameters with their descriptions are listed in GlidingConfig.


Notes

There is a GlidingCollectionDelegate protocol which can notify you when item in GlidingCollection didSelect, willExpand and didExpand.

If you want to achieve a parallax effect on a horizontal cards stack, you need to place your parallax view in a cell’s contentView and set its tag to 99.

parallax-view

There is a kGlidingCollectionParallaxViewTag constant if you want to layout a cell in code.

  1. imageView.tag = kGlidingCollectionParallaxViewTag

📄 License

Gliding Collection is released under the MIT license.
See LICENSE for details.

This library is a part of a selection of our best UI open-source projects.

If you use the open-source library in your project, please make sure to credit and backlink to https://www.ramotion.com/

📱 Get the Showroom App for iOS to give it a try

Try this UI component and more like this in our iOS app. Contact us if interested.