Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Reusable GridView with excellent performance and customization that can be time table, spreadsheet, paging and more.

License

NotificationsYou must be signed in to change notification settings

KyoheiG3/GridView

Repository files navigation

Build StatusCarthage compatibleVersionLicensePlatform

GridView can tile the view while reusing it. It has an API like UIKit that works fast. Even when device rotates it smoothly relayout.

timetabletimetable

You Can

  • Scroll like paging
  • Scroll infinitely
  • Scale the view
  • Call API like theUITableView

Requirements

  • Swift 5.0
  • iOS 9.0 or later

How to Install

CocoaPods

Add the following to yourPodfile:

pod"G3GridView"

⚠️WARNING : If you want to install fromCocoaPods, must addG3GridView to Podfile because there is aGridView different from thisGridView.

Carthage

Add the following to yourCartfile:

github"KyoheiG3/GridView"

Over View

GridView can scroll in any direction while reusing Cell likeUITableView. Also it is basedUIScrollView and paging and scaling are possible. If necessary, it is possible to repeat the left and right scroll infinitely.

GridView is oneUIScrollView, but the range which Cell is viewed depends on Superview. Cell reuse is also done within the range which Superview is viewed, so its size is very important.

On the other hand, scaling and paging depend to position and size of GridView. 'bounds' is important for paging, 'frame' is important in scaling. The same is true for offset of content.

The following image is a visual explanation of the view hierarchy.

Hierarchy

You can use it like theUITableView APIs. However, there is concept ofColumn. The following functions are delegate APIs of 'GridView'.

func gridView(_ gridView:GridView, numberOfRowsInColumn column:Int)-> Intfunc gridView(_ gridView:GridView, cellForRowAt indexPath:IndexPath)-> GridViewCell@objc optionalfunc numberOfColumns(in gridView:GridView)->Int

You can see that must return the count.

Examples

This project is including two examples that is timetable and paging. Those can change on Interface Builder for following:

Example

Try the two examples.

timetablepaging
timetablepaging

Usage

Variables

Infinite Loop

A horizontal loop is possible.

openvarisInfinitable:Bool
  • Default istrue.
  • Setfalse if you don't need to loop of view.

loop

gridView.isInfinitable=true

Scaling

Content is done relayout rather than scaling like 'UIScrollView'.

openvarminimumScale:ScaleopenvarmaximumScale:Scale
  • Default for x and y are 1.
  • Set the vertical and horizontal scales.
publicvarcurrentScale:Scale{get}
  • Get current vertical and horizontal scales.

scaling

gridView.minimumScale=Scale(x:0.5, y:0.5)gridView.maximumScale=Scale(x:1.5, y:1.5)

Fill for Cell

It is possible to decide the placement of Cell at relayout.

openvarlayoutWithoutFillForCell:Bool
  • Default isfalse.
  • Settrue if need to improved view layout performance.
falsetrue
falsetrue
gridView.layoutWithoutFillForCell=true

Content Offset

IfisInfinitable is true,contentOffset depends on the content size including size to loop. It is possible to take content offset that actually visible.

openvaractualContentOffset:CGPoint{get}

Delegate

Set the delegate destination. This delegate property isUIScrollViewDelegate but, actually set theGridViewDelegate.

weak open var dataSource: GridViewDataSource?open var delegate: UIScrollViewDelegate?

Functions

State

Get the view state.

publicfunc visibleCells<T>()->[T]publicfunc cellForRow(at indexPath:IndexPath)->GridViewCell?publicfunc rectForRow(at indexPath:IndexPath)->CGRectpublicfunc indexPathsForSelectedRows()->[IndexPath]publicfunc indexPathForRow(at position:CGPoint)->IndexPath

Operation

Operate the view.

publicfunc contentScale(_ scale:CGFloat)publicfunc reloadData()publicfunc invalidateContentSize()publicfunc invalidateLayout(horizontally:Bool= default)publicfunc deselectRow(at indexPath:IndexPath)override openfunc setContentOffset(_ contentOffset:CGPoint, animated:Bool)publicfunc scrollToRow(at indexPath:IndexPath, at scrollPosition:GridViewScrollPosition= default, animated:Bool= default)

LICENSE

Under the MIT license. SeeLICENSE file for details.

About

Reusable GridView with excellent performance and customization that can be time table, spreadsheet, paging and more.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp