All Projects → Antondomashnev → Admozaiccollectionviewlayout

Antondomashnev / Admozaiccollectionviewlayout

Licence: mit
ADMozaicCollectionViewLayout is yet another UICollectionViewLayout subclass that implements "brick", "mozaic" or Pinterest style layout.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Admozaiccollectionviewlayout

Centeredcollectionview
A lightweight UICollectionViewLayout that 'pages' and centers its cells 🎡 written in Swift
Stars: ✭ 965 (+326.99%)
Mutual labels:  cocoapods, carthage, uicollectionviewlayout, uicollectionview
Gemini
Gemini is rich scroll based animation framework for iOS, written in Swift.
Stars: ✭ 2,965 (+1211.95%)
Mutual labels:  cocoapods, carthage, uicollectionview
Persei
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift
Stars: ✭ 3,395 (+1402.21%)
Mutual labels:  cocoapods, carthage, uicollectionview
HorizontalStickyHeaderLayout
Horizontal UICollectionViewLayout with Sticky HeaderView
Stars: ✭ 70 (-69.03%)
Mutual labels:  uicollectionview, carthage, uicollectionviewlayout
Koyomi
Simple customizable calendar component in Swift 📆
Stars: ✭ 716 (+216.81%)
Mutual labels:  cocoapods, carthage, uicollectionview
Closures
Swifty closures for UIKit and Foundation
Stars: ✭ 1,720 (+661.06%)
Mutual labels:  cocoapods, carthage, uicollectionview
Sffocusviewlayout
UICollectionViewLayout with focused content
Stars: ✭ 1,760 (+678.76%)
Mutual labels:  cocoapods, carthage, uicollectionviewlayout
Theanimation
Type-safe CAAnimation wrapper. It makes preventing to set wrong type values.
Stars: ✭ 214 (-5.31%)
Mutual labels:  cocoapods, carthage
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 (-18.58%)
Mutual labels:  uicollectionviewlayout, uicollectionview
Infinitecollectionview
Infinite horizontal scrolling using UICollectionView.
Stars: ✭ 218 (-3.54%)
Mutual labels:  cocoapods, uicollectionview
Imagetransition
Library for smooth animation of images during transitions.
Stars: ✭ 195 (-13.72%)
Mutual labels:  cocoapods, carthage
Amplitude Ios
Native iOS/tvOS/macOS SDK
Stars: ✭ 216 (-4.42%)
Mutual labels:  cocoapods, carthage
Collor
A declarative-ui framework for UICollectionView with great and useful features.
Stars: ✭ 182 (-19.47%)
Mutual labels:  cocoapods, uicollectionview
Iso8601
ISO8601 date parser and writer
Stars: ✭ 213 (-5.75%)
Mutual labels:  cocoapods, carthage
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (-21.68%)
Mutual labels:  cocoapods, carthage
Swiftyanimate
Composable animations in Swift
Stars: ✭ 194 (-14.16%)
Mutual labels:  cocoapods, carthage
Icimulator
Simulate camera functions on iOS Simulator with images, videos, or your MacBook Camera.
Stars: ✭ 177 (-21.68%)
Mutual labels:  cocoapods, carthage
Whatsnewkit
Showcase your awesome new app features 📱
Stars: ✭ 2,329 (+930.53%)
Mutual labels:  cocoapods, carthage
Pincache
Fast, non-deadlocking parallel object cache for iOS, tvOS and OS X
Stars: ✭ 2,513 (+1011.95%)
Mutual labels:  cocoapods, carthage
Aksidemenu
Beautiful iOS side menu library with parallax effect. Written in Swift
Stars: ✭ 216 (-4.42%)
Mutual labels:  cocoapods, carthage

ADMozaicCollectionViewLayout

Carthage compatible CocoaPods Compatible codebeat badge

What is it

ADMozaicCollectionViewLayout is yet another UICollectionViewLayout subclass that implements "brick" or "mozaic" layout.

example

Why do anybody need yet another one?

Because there are plenty of kind of the same layouts already:

But this project is pure swift implementation, so if you don't want to mess up objective-c code and swift you are on the right page. Also, as an advantage compares to another "mozaic" layout - you're not limited to predefined sizes of cells.

Usage

The idea behind this layout is to split UICollectionView bounds into some kind of "matrix". To do this ADMozaikCollectionViewLayout requires height for rows and width for columns in specific section.

/// Designated initializer for `ADMozaikLayout`
///
/// - Parameter delegate: delegate/datasource for the layout
public init(delegate: ADMozaikLayoutDelegate)

It requires the delegate object conforms to protocol ADMozaikLayoutDelegate. The first required method is to return the size of each item in layout:

/// Method should return `ADMozaikLayoutSize` for specific indexPath
///
/// - Parameter collectionView: collection view is using layout
/// - Parameter layout:         layout itself
/// - Parameter indexPath:      indexPath of item for the size it asks for
///
/// - Returns: `ADMozaikLayoutSize` struct object describes the size
func collectionView(_ collectionView: UICollectionView, mozaik layout: ADMozaikLayout, mozaikSizeForItemAt indexPath: IndexPath) -> ADMozaikLayoutSize

Where ADMozaikLayoutSize describes the size of each cell in terms of ADMozaikCollectionViewLayout

/**
 *  Defines the size of the layout item
 */
public struct ADMozaikLayoutSize {
  /// Columns number that item requires
  let columns: Int
  /// Rows number that item requires
  let rows: Int
}

The second method is to get the geometry information for each specific section of layout:

/// Method should return `ADMozaikLayoutSectionGeometryInfo` to describe specific section's geometry
///
/// - Parameters:
///   - collectionView: collection view is using layout
///   - layoyt:         layout itself
///   - section:        section to calculate geometry info for
///
/// - Returns: `ADMozaikLayoutSectionGeometryInfo` struct object describes the section's geometry
func collectonView(_ collectionView: UICollectionView, mozaik layoyt: ADMozaikLayout, geometryInfoFor section: ADMozaikLayoutSection) -> ADMozaikLayoutSectionGeometryInfo

Where ADMozaikLayoutSectionGeometryInfo describes the all geometry parameters of the section

/**
 *  Defines the layout's information
 */
public struct ADMozaikLayoutSectionGeometryInfo {
  /// array of `ADMozaikLayoutColumn` for the layout
  let columns: [ADMozaikLayoutColumn]

  /// height for each row in points
  let rowHeight: CGFloat

  /// minimum space between items
  let minimumInteritemSpacing: CGFloat

  /// minimum space between each row
  let minimumLineSpacing: CGFloat

  /// Insets for the section from top, left, right, bottom
  let sectionInset: UIEdgeInsets

  /// Height for header in section
  /// Width is currently limited to the collection view width
  let headerHeight: CGFloat

  /// Height for footer in section
  /// Width is currently limited to the collection view width
  let footerHeight: CGFloat
}

Content mode options

/// Method should return `ADMozaikLayoutSectionContentMode` to describe specific section's geometry
///
/// - Parameters:
///   - collectionView: collection view is using layout
///   - layout:         layout itself
///   - section:        section to return content mode for
///
/// - Returns: `ADMozaikLayoutSectionContentMode` enum describes the section's content mode and how to position cells
func collectonView(_ collectionView: UICollectionView, mozaik layout: ADMozaikLayout, contentModeFor section: ADMozaikLayoutSection) -> ADMozaikLayoutSectionContentMode

The contentMode option controls the way how the Mozaik layout is filled with items:

  1. fill - tries to fill vacant spaces with item;
  2. ordered - keeps order of the provided items, so empty space can appear in the collection view.

For the complete example please check the example project. Note that current example project is supposed to be run on iPhone 8 screen's size.

Install

CocoaPods

To integrate ADMozaicCollectionViewLayout into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'ADMozaicCollectionViewLayout', '~> 4.0'

Carthage

To integrate ADMozaicCollectionViewLayout into your Xcode project using Carthage, specify it in your Cartfile:

github "Antondomashnev/ADMozaicCollectionViewLayout" ~> 4.0

Run carthage update to build the framework and drag the built ADMozaikCollectionViewLayout.framework into your Xcode project.

Migration guide

License

ADMozaicCollectionViewLayout is available under the MIT license. See LICENSE for more information.

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].