All Projects → magi82 → MGGridView

magi82 / MGGridView

Licence: MIT license
MGGridView is a grid view created by a combination of collection views.

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to MGGridView

Rxasdatasources
RxDataSource for AsyncDisplayKit/Texture
Stars: ✭ 114 (+356%)
Mutual labels:  collectionview
Collectionviewslantedlayout
A CollectionView Layout displaying a slanted cells
Stars: ✭ 2,029 (+8016%)
Mutual labels:  collectionview
Async Expandable List
Stars: ✭ 221 (+784%)
Mutual labels:  collectionview
Planadscrollview
使用CollectionView实现的轮播图,丝滑的流畅,支持网络图片和本地图片轮播,混合也是支持的!
Stars: ✭ 117 (+368%)
Mutual labels:  collectionview
Rxrealmdatasources
An easy way to bind an RxRealm observable to a table or collection view
Stars: ✭ 154 (+516%)
Mutual labels:  collectionview
Vbpiledview
Simple and beautiful stacked UIView to use as a replacement for an UITableView, UIImageView or as a menu
Stars: ✭ 164 (+556%)
Mutual labels:  collectionview
Wbcollectionviewlayout
Library used to provide different type of custom Layouts within 30 second of time
Stars: ✭ 105 (+320%)
Mutual labels:  collectionview
Reactivelists
React-like API for UITableView & UICollectionView
Stars: ✭ 250 (+900%)
Mutual labels:  collectionview
Infinitescrolling
Add infinite scrolling to collection view.
Stars: ✭ 156 (+524%)
Mutual labels:  collectionview
Pinterestlayout
Custom collection view layout inspired by Pinterest layout. Written in Swift.
Stars: ✭ 219 (+776%)
Mutual labels:  collectionview
Emptykit
A lightweight, swift library for displaying emptyView whenever the view(tableView/collectionView) has no content to display, just like DZNEmptyDataSet
Stars: ✭ 117 (+368%)
Mutual labels:  collectionview
Squareflowlayout
🌄 UICollectionViewLayout subclass inspired by Instagram Discover page style layout.
Stars: ✭ 142 (+468%)
Mutual labels:  collectionview
Chatlayout
ChatLayout is an alternative solution to MessageKit. It uses custom UICollectionViewLayout to provide you full control over the presentation as well as all the tools available in UICollectionView. It supports dynamic cells and supplementary view sizes.
Stars: ✭ 184 (+636%)
Mutual labels:  collectionview
Pull To Refresh
ESPullToRefresh is developed and maintained by Vincent Li. If you have any questions or issues in using ESPullToRefresh, welcome to issue. If you want to contribute to ESPullToRefresh, Please submit Pull Request, I will deal with it as soon as possible.
Stars: ✭ 1,591 (+6264%)
Mutual labels:  collectionview
Compositionaldiffableplayground.ios
Examples showing Compositional Layout, Diffable Data Sources and more!
Stars: ✭ 229 (+816%)
Mutual labels:  collectionview
Collectionview
An easy to use, highly customizable replacement for NSCollectionView.
Stars: ✭ 107 (+328%)
Mutual labels:  collectionview
Zkcarousel
A simple carousel implementation written in Swift
Stars: ✭ 163 (+552%)
Mutual labels:  collectionview
MMAdvertScrollView
一个简单、轻量级的swift版公告轮播框架
Stars: ✭ 42 (+68%)
Mutual labels:  collectionview
Rxdatasources
UITableView and UICollectionView Data Sources for RxSwift (sections, animated updates, editing ...)
Stars: ✭ 2,784 (+11036%)
Mutual labels:  collectionview
Swipetableview
Both scroll horizontal and vertical for segment scrollview which have a same header. — 类似半糖、美丽说主页与QQ音乐歌曲列表布局效果,实现不同菜单的左右滑动切换,同时支持类似tableview的顶部工具栏悬停(既可以左右滑动,又可以上下滑动)。兼容下拉刷新,自定义 collectionview实现自适应 contentSize 还可实现瀑布流功能
Stars: ✭ 2,252 (+8908%)
Mutual labels:  collectionview

MGGridView

Swift Platform Version Carthage compatible License

MGGridView is a grid view created by a combination of collection views.
Apple's collection view method is simple and easy to implement. ☀️

MGGridView can be created in the storyboard.
In Carthage, however, it is programmatically only.
Carthage Issues #763

The column cell does not support registration in the storyboard.
You can implement it programmatically or with xib.

Sample

Usage

  • Declare the MGGridView, and add the data to the data source.
var gridView: MGGridView? = nil
let menus: [[String]] = [
    ["1-1", "1-2", "1-3", "1-4", "1-5", "1-6", "1-7", "1-8", "1-9", "1-10"],
    ["2-1", "2-2", "2-3", "2-4", "2-5", "2-6", "2-7", "2-8", "2-9", "2-10"],
    ["3-1", "3-2", "3-3", "3-4", "3-5", "3-6", "3-7", "3-8", "3-9", "3-10"],
    ["4-1", "4-2", "4-3", "4-4", "4-5", "4-6", "4-7", "4-8", "4-9", "4-10"],
    ["5-1", "5-2", "5-3", "5-4", "5-5", "5-6", "5-7", "5-8", "5-9", "5-10"],
    ["6-1", "6-2", "6-3", "6-4", "6-5", "6-6", "6-7", "6-8", "6-9", "6-10"],
    ["7-1", "7-2", "7-3", "7-4", "7-5", "7-6", "7-7", "7-8", "7-9", "7-10"],
    ["8-1", "8-2", "8-3", "8-4", "8-5", "8-6", "8-7", "8-8", "8-9", "8-10"],
    ["9-1", "9-2", "9-3", "9-4", "9-5", "9-6", "9-7", "9-8", "9-9", "9-10"]
  ]
  • Create an MGGridView and configure.
gridView = MGGridView(frame: UIScreen.main.bounds,
                      collectionViewLayout: UICollectionViewFlowLayout())
if let grid = gridView {
  grid.backgroundColor = .white
  grid.register(MGGridViewCell.self,
                    forCellWithReuseIdentifier: "row")
  grid.configure(delegate: self)
  self.view.addSubview(grid)
}
  • Implement a data source and delegate for MGGridView.
    You can do the same as the collection view.
  • Important!!!! Here's what's important.
    You need to config for the column in the grid view.
// Implementing delegate and data source
extension ViewController: MGGridViewDelegate, MGGridViewDataSource {
  func gridView(_ gridView: UICollectionView,
                cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = gridView.dequeueReusableCell(withReuseIdentifier: "row",
                                            for: indexPath) as! MGGridViewCell
    
    // Important!! You need to configure for column.
    cell.configure { view, layout in
      layout.scrollDirection = .horizontal
      
      view.showsHorizontalScrollIndicator = false
      view.showsVerticalScrollIndicator = false
      view.register(UICollectionViewCell.self,
                    forCellWithReuseIdentifier: "column")
    }
    
    return cell
  }
  
  func gridView(_ gridView: UICollectionView,
                numberOfItemsInSection section: Int) -> Int {
    return menus.count
  }
}
  • If necessary, also implement a Layout delegate.
// Row layout delegate implementation
extension ViewController: MGGridViewDelegateFlowLayout {
  func gridView(_ gridView: UICollectionView,
                layout gridViewLayout: UICollectionViewLayout,
                sizeForItemAt indexPath: IndexPath) -> CGSize {
    return CGSize(width: UIScreen.main.bounds.width, height: 100)
  }
}
  • Implements a delegate for the column cell of MGGridView.
  • Important!!!! Here's what's important.
    In a delegate implementation, collectionView.tag is the row index of the corresponding grid view.
// Delegate implementation for column
extension ViewController: UICollectionViewDelegate, UICollectionViewDataSource {
  func collectionView(_ collectionView: UICollectionView,
                      numberOfItemsInSection section: Int) -> Int {
    // Tag is the row index of the grid view.
    return menus[collectionView.tag].count
  }
  
  func collectionView(_ collectionView: UICollectionView,
                      cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "column",
                                                  for: indexPath) as! ColumnCollectionViewCell
    
    cell.title.text = menus[collectionView.tag][indexPath.row]
    return cell
  }
}
  • You can also implement the Layout delegate as needed.
// Row layout delegate implementation
extension ViewController: UICollectionViewDelegateFlowLayout {
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
    return CGSize(width: 80, height: 80)
  }
}

Aid

Requirements

  • Swift 3.0+
  • Xcode 8.0+
  • iOS 8.0+

Installation

pod 'MGGridView', '~> 0.1.1'
github "magi82/MGGridView ~> 0.1.1"

Author

magi82, [email protected]

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].