SwiftUI views that arrange their children in a Pinterest-like layout

Overview

SwiftUI Masonry

SwiftUI views that arrange their children in a Pinterest-like layout.

Demo

HMasonry

A view that arranges its children in a horizontal masonry.

Usage

ScrollView(.horizontal) {
    HMasonry(rows: 2) {
        //Masonry content
    }
}

Parameters

  • rows: The number of rows in the masonry.
  • placementMode: The placement of subviews in the masonry.
  • horizontalSpacing: The distance between horizontally adjacent subviews, or nil if you want the masonry to choose a default distance for each pair of subviews.
  • verticalSpacing: The distance between vertically adjacent subviews, or nil if you want the masonry to choose a default distance for each pair of subviews.
  • content: A view builder that creates the content of this masonry.

VMasonry

A view that arranges its children in a vertical masonry.

Usage

ScrollView(.vertical) {
    VMasonry(columns: 2) {
        //Masonry content
    }
}

Parameters

  • columns: The number of columns in the masonry.
  • placementMode: The placement of subviews in the masonry.
  • horizontalSpacing: The distance between horizontally adjacent subviews, or nil if you want the masonry to choose a default distance for each pair of subviews.
  • verticalSpacing: The distance between vertically adjacent subviews, or nil if you want the masonry to choose a default distance for each pair of subviews.
  • content: A view builder that creates the content of this masonry.

Masonry

A view that arranges its children in a masonry.

Usage

ScrollView(.vertical) {
    Masonry(.vertical, lines: .adaptive(minSize: 140)) {
        //Masonry content
    }
}

Parameters

  • axis: The layout axis of this masonry.
  • lines: The number of lines in the masonry.
  • placementMode: The placement of subviews in the masonry.
  • horizontalSpacing: The distance between horizontally adjacent subviews, or nil if you want the masonry to choose a default distance for each pair of subviews.
  • verticalSpacing: The distance between vertically adjacent subviews, or nil if you want the masonry to choose a default distance for each pair of subviews.
  • content: A view builder that creates the content of this masonry.

Requirements

  • iOS 14.0+, macOS 11.0+, tvOS 14.0+ or watchOS 7.0+
  • Xcode 12.0+

Installation

Contact

@ciaranrobrien on Twitter.

You might also like...
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Extremely Fast views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainabl

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Auto Layout (and manual layout) in one line.
Auto Layout (and manual layout) in one line.

Auto Layout (and manual layout) in one line. Quick Look view.bb.centerX().below(view2).size(100) Itโ€™s equivalent to iOS 9 API: view.centerXAnchor.cons

Auto Layout made easy with the Custom Layout.
Auto Layout made easy with the Custom Layout.

Auto Layout made easy with the Custom Layout. Getting started CocoaPods CocoaPods is a dependency manager for Cocoa projects. You can install it with

AppStoreClone - Understanding the complex layout of app store using UICompositional layout in swift
AppStoreClone - Understanding the complex layout of app store using UICompositional layout in swift

AppStoreClone Understanding the complex layout of app store using UICompositiona

Apple provides us two ways to use UIKit views in SwiftUI

RepresentableKit Apple provides us two ways to use UIKit views in SwiftUI: UIVie

An experiment creating a particle emitter using the new TimelineView and Canvas views in SwiftUI
An experiment creating a particle emitter using the new TimelineView and Canvas views in SwiftUI

Particle Emitter An experiment creating a particle emitter using the new Timelin

SwiftUI stack views with paged scrolling behaviour.

SwiftUI PageView SwiftUI stack views with paged scrolling behaviour. HPageView A view that arranges its children in a horizontal line, and provides pa

Flow layout / tag cloud / collection view in SwiftUI.
Flow layout / tag cloud / collection view in SwiftUI.

SwiftUIFlowLayout A Flow Layout is a container that orders its views sequentially, breaking into a new "line" according to the available width of the

Comments
  • Request to add tagged Releases

    Request to add tagged Releases

    Hi @ciaranrobrien, Thanks so much for creating a great masonry view. It's working really well for us!

    Would you be up for adding a tag with a version number in GitHub? There's a nice article documenting it here: https://appracatappra.com/2021/07/releasing-and-versioning-your-swift-package/#Versioning-your-Swift-Package-on-GitHub. It should be pretty simple. The advantage is that we can then point to a specific version and get to chose to update at a time that suits us rather than whatever's the latest.

    Thanks again! Harry

    opened by harry-lush 0
  • Need Lazy loading

    Need Lazy loading

    Layout seems to load all the items immediately, this doesn't really work with 1k+ images as all of them loaded immediately and lags the app. Any plans to include this?

    opened by AugustDev 0
Owner
Ciaran O'Brien
Ciaran O'Brien
Arrange views in your appโ€™s interface using layout tools that SwiftUI provides.

Composing custom layouts with SwiftUI Arrange views in your app's interface using layout tools that SwiftUI provides. Overview This sample app demonst

Apple Sample Code 0 Jun 9, 2022
๐ŸฅบPinterest Layout Tutorial

PinterestTutorial-iOS ?? Pinterest Layout Tutorial ์ด๋ฏธ์ง€ ํฌ๊ธฐ์— ๋”ฐ๋ผ์„œ ๋™์ ์œผ๋กœ ์…€์˜ ๋ ˆ์ด์•„์›ƒ์„ ์„ค์ •ํ•˜๋Š” ํ•€ํ„ฐ๋ ˆ์ŠคํŠธ ๋ ˆ์ด์•„์›ƒ ๊ตฌํ˜„ํ•ด ๋ณด์•˜๋‹ค. ์™„์„ฑ ์ฝ”๋“œ UICollectionViewDelegateFlowLayout ์˜ ์„œ๋ธŒํด๋ž˜์Šค

Hyungyu Kim 6 May 10, 2022
Allows users to pull in new song releases from their favorite artists and provides users with important metrics like their top tracks, top artists, and recently played tracks, queryable by time range.

Spotify Radar Spotify Radar is an iOS application that allows users to pull in new song releases from their favorite artists and provides users with i

Kevin Li 630 Dec 13, 2022
๐Ÿฅณ Give birthday celebration message to foster children ๐ŸŽ‚

GiveCake Team Icon ๋””์ž์ด๋„ˆ์™€ ๊ฐœ๋ฐœ์ž -> DBAL App Icon Introduction ๊ฒฝ๋ถ ์œ„ํƒ๊ฐ€์ •๊ณผ ๊ธฐ๋ถ€์ž ์‚ฌ์ด์—์„œ ์ผ€์ต ๊ธฐ๋ถ€๋ฅผ ์œ„ํ•œ ๋ˆ๋งŒ ๋ณด๋‚ด๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ์ถ•ํ•˜์™€ ๊ฐ์‚ฌ์˜ ๋งˆ์Œ ๋˜ํ•œ ์„œ๋กœ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ์•ฑ์ž…๋‹ˆ๋‹ค. Functions ๊ธฐ

๊ฐœ๋ฐœ์ž์•„์นด๋ฐ๋ฏธ_ํฌ์Šคํ… 4 Jul 29, 2022
Expose layout margins and readable content width to SwiftUI's Views

SwiftUI Layout Guides This micro-library exposes UIKit's layout margins and readable content guides to SwiftUI. Usage Make a view fit the readable con

Thomas Grapperon 26 Dec 23, 2022
Reframing SwiftUI Views. A collection of tools to help with layout.

Overview A Swift Package with a collection of SwiftUI framing views and tools to help with layout. Size readers like WidthReader, HeightReader, and on

Ryan Lintott 84 Dec 16, 2022
A custom layout built on top of SwiftUI's Layout API that lays elements out in multiple lines. Similar to flex-wrap in CSS, CollectionViewFlowLayout.

WrapLayout A custom layout built on top of SwiftUI's Layout API that lays elements out in multiple lines. Similar to flex-wrap in CSS, CollectionViewF

Hiroshi Kimura 6 Sep 27, 2022
Swift-picker-views - inline single and multi picker views for UIKit. Without tableview! Easy and simple

swift-picker-views Inline single and multiple picker views for UIKit. No tablevi

IBRAHIM YILMAZ 2 Jan 31, 2022
A Swift utility to make updating table views/collection views trivially easy and reliable.

ArrayDiff An efficient Swift utility to compute the difference between two arrays. Get the removedIndexes and insertedIndexes and pass them directly a

Adlai Holler 100 Jun 5, 2022
A mental health app designed to help users track their emotions with short, tweet-like journals.

Objective The purpose of this project is to create a mental health app where users will input a short journal each day that is no longer than a tweet

Isha Mahadalkar 0 Dec 25, 2021