• Stars
    star
    309
  • Rank 135,306 (Top 3 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A UICollectionViewFlowLayout subclass that scales items to take up space, optimized for large item set, inspired by NHBalancedFlowLayout.

ZLBalancedFlowLayout

A UICollectionViewFlowLayout subclass that scales items to take up space, optimized for large item set, inspired by NHBalancedFlowLayout.

Previews

###UICollectionViewScrollDirectionVertical ###UICollectionViewScrollDirectionHorizontal

CocoaPods

You can install ZLBalancedFlowLayout through CocoaPods adding the following to your Podfile:

pod 'ZLBalancedFlowLayout'

CocoaPods' support for swift is still pre-released, and requires your iOS deployment target to be 8.0 or later:

[sudo] gem install cocoapods --pre

Usage

Checkout the demo app for an example.

ZLBalancedFlowLayout supports all properties of UICollectionViewFlowLayout and the corresponding delegate methods, including minimumLineSpacing, minimumInteritemSpacing, sectionInset, etc.

Use rowHeight to adjust the item height.

/// The ideal row height of items in the grid
var rowHeight = CGFloat(100)

/// The option to enforce the ideal row height by changing the aspect ratio of the item if necessary.
var enforcesRowHeight = false

Benchmarks

ZLBalancedFlowLayout uses dynamic programming techniques to find the optimal partition of cells upfront. The benchmarks are based on timings of prepareLayout:

###iPhone 6

NumSections NumItemsPerSection ZLBalancedFlowLayout UICollectionViewFlowLayout
1 100 0.0517209768295288 0.00196903944015503
1 1000 0.565874993801117 0.0149750113487244
1 3000 Recursion overflow, not yet tail optimized 0.0408549904823303
10 100 0.523442983627319 0.0157199501991272
10 1000 5.28750801086426 0.130671977996826
100 100 4.89241003990173 0.118210017681122

###iOS simulator

NumSections NumItemsPerSection ZLBalancedFlowLayout UICollectionViewFlowLayout
1 100 0.0160560011863708 0.000555038452148438
1 1000 0.228259027004242 0.0039139986038208
1 3000 1.20643001794815 0.0141730308532715
10 100 0.158486008644104 0.0039370059967041
10 1000 2.26102298498154 0.0399309992790222
100 100 1.60317003726959 0.0364070534706116
100 1000 21.678355038166 0.385994970798492

Requirements

  • iOS 6 or higher.
  • Automatic Reference Counting (ARC).

License

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

Photo Credits

The photos in the demo app are selected from National Geographic

More Repositories

1

ZLSwipeableView

A simple view for building card like interface inspired by Tinder and Potluck.
Objective-C
2,828
star
2

ZLSwipeableViewSwift

A simple view for building card like interface inspired by Tinder and Potluck.
Swift
2,235
star
3

ZLSinusWaveView

A Siri like voice visualization view using EZAudio. Modified from SISinusWaveView for iOS.
Objective-C
283
star
4

ZLMusicFlowWaveView

A ZLSinusWaveView subclass inspired by 乐流/MusicFlow
Objective-C
202
star
5

ZLPeoplePickerViewController

A multilingual replacement for ABPeoplePickerNavigationController (address book picker) that supports UILocalized​Indexed​Collation
Objective-C
189
star
6

ZLHistogramAudioPlot

A hardware-accelerated audio visualization view using EZAudio, inspired by AudioCopy.
Objective-C
185
star
7

UIColor-ChineseTraditionalColors

A swift extension that extends UIColor with a list of Chinese traditional colors
Swift
132
star
8

AsyncTask

An asynchronous programming library for Swift
Swift
130
star
9

react-webgl-globe-basic-example

WebGL Globe basic example in react
JavaScript
70
star
10

Async

Async, await control flow for Swift.
Swift
69
star
11

Algorithms

Answers to LeetCode questions in Swift and JavaScript
Swift
52
star
12

ReactiveUI

A lightweight replacement for target action with closures, modified from Scream.swift.
Swift
51
star
13

Emoticon

An Emoticon Keyboard
Swift
22
star
14

wwdc

WWDC 2015 Student Scholarship App
Swift
6
star
15

printf

A web based visualizer for printf format string
JavaScript
6
star
16

YelpAPI

Yelp API in Swift
Swift
5
star
17

TicketsTonight

UCLA CS130 Fall 2014 Class Project
Objective-C
4
star
18

AlamofireAsync

Async extension for Alamofire
Swift
3
star
19

DongerListKeyboard

Experimenting with iOS 8 keyboard in swift
Objective-C
3
star
20

JSTester

A simple structure tester for javascript programs.
JavaScript
1
star
21

librarymanagement

Python
1
star
22

frappe_app_template

1
star