GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - min/Lay: An iOS library that computes a perfectly justified collection of elements for any given width.

BranchesTags
Open more actions menu

Latest commit

 

History

8 Commits
8 Commits

Folders and files

NameName
Last commit message
Last commit date
Example
Example
 
 
Lay.xcodeproj
Lay.xcodeproj
 
 
Lay
Lay
 
 
LayTests
LayTests
 
 
docs
docs
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

Computes a perfectly justified collection of elements for any given width while maintaining the source aspect ratio. This library aims to mimic the layout implementations found in:

  • Flickr
  • Chromatic
  • Google photos

At it's core, Lay applies the linear partitioning algorithm against the aspect ratios of each size element to compute the balanced layout.

Features

  • No cropping, source size aspect ratios will be maintained.
  • Flexible, works with any array of elements that conform to the Sizable protocol.
  • Swift 3.0

Checkout out the Example app to see how this can be integrated with UICollectionViews.

This project is heavily inspired by this article written by Johannes Treitz.

Usage

import Lay

let aspectRatios: [CGSize] = [
	.init(width: 100, height: 100),
	.init(width: 80, height: 120),
	.init(width: 100, height: 100),
	.init(width: 200, height: 200),
	.init(width: 80, height: 100),
	.init(width: 100, height: 120),
	.init(width: 100, height: 80)
]

// Can now use these sizes to render your elements however you want

let sizes: [CGSize] = aspectRatios.lay_justify(for: view.bounds.size.width)

>>> [
      (140.0, 140.0),
      (93.0, 140.0),
      (142.0, 140.0),
      (208.0, 208.0),
      (167.0, 208.0),
      (150.0, 180.0),
      (225.0, 180.0)
    ]

TODO

  • Tests
  • Cocoapods support

Requirements

  • Xcode 8.0+
  • iOS 9.0+
  • Swift 3.0

Installation

Carthage

For Carthage, add the following to your Cartfile:

github "min/Lay" ~> 0.1.0

About

An iOS library that computes a perfectly justified collection of elements for any given width.

Resources

Readme
License
Activity

Stars

20 stars

Watchers

0 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.