GlidingCollection 2.1.0

GlidingCollection 2.1.0

测试已测试
语言语言 SwiftSwift
许可 MIT
版本最新版本2019年4月
SPM支持SPM

Abdurahim JauzeeAdaptive ControllerAlex Kalinkin维护。



  • 由:
  • Abdurahim Jauzee

GLIDING COLLECTION

一个为UICollectionView Swift Controller提供的平滑、可自定义的选择


我们专注于设计和为移动应用程序和网站编写自定义UI。

关注最新更新

为您的项目获取免费模拟图 →

Twitter PodPlatform PodVersion Documentation Carthage Codebeat Swift Donate

要求

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

安装

您可以通过多种方式安装 GlidingCollection

  • 将源文件添加到您的项目中。

pod 'GlidingCollection'

github "Ramotion/gliding-collection"

如何使用

• 创建一个视图控制器类

import GlidingCollection

class ViewController: UIViewController {
  let items = ["gloves", "boots", "bindings", "hoodie"]
}

• 将一个 UIView 拖到画布上。将其类更改为 GlidingCollection 并使用自动布局约束。

step-2

• 将此视图连接到您的视图控制器类作为 @IBOutlet

@IBOutlet var glidingCollection: GlidingCollection!

• 让您的视图控制器符合 GlidingCollectionDatasource。它与您所知道的 UITableViewUICollectionView数据源 协议非常相似

extension ViewController: GlidingCollectionDatasource {

  func numberOfItems(in collection: GlidingCollection) -> Int {
    return items.count
  }

  func glidingCollection(_ collection: GlidingCollection, itemAtIndex index: Int) -> String {
    return "" + items[index]
  }

}

• 让您的视图控制器符合 UICollectionViewDatasource

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

自定义

您可以通过覆盖 GlidingConfigshared 实例来自定义 GlidingCollection 的外观。

var config = GlidingConfig.shared
config.buttonsFont = UIFont.boldSystemFont(ofSize: 22)
config.activeButtonColor = .black
config.inactiveButtonsColor = .lightGray
GlidingConfig.shared = config

🗒所有参数及其描述都在 GlidingConfig 中列出。


备注

存在一个 GlidingCollectionDelegate 协议,当 GlidingCollection 中的 item 发生 didSelectwillExpanddidExpand 事件时,会通知你。

如果你想在一个水平卡片堆栈上实现视差效果,你需要将你的 视差视图 放置在单元格的 contentView 中,并将其 tag 设置为 99

parallax-view

如果你想要在代码中布局单元格,可以使用 kGlidingCollectionParallaxViewTag 常量。

imageView.tag = kGlidingCollectionParallaxViewTag

📄许可

Gliding Collection 以 MIT 许可证发布。有关详细信息,请参阅 LICENSE

这个库是我们优秀的 UI 开源项目之一精选之一。

如果你的项目中使用了开源库,请确保给予信用并链接到 www.ramotion.com

📱尝试 iOS 的商店应用

在我们的 iOS 应用中尝试这个 UI 组件以及其他类似的组件。如果您感兴趣,请与我们联系。