SwiftUI views that arrange their children in a flow layout.

Related tags

Layout SwiftUIFlow
Overview

SwiftUI Flow

SwiftUI views that arrange their children in a flow layout.

Demo

HFlow

A view that arranges its children in a horizontal flow.

Usage

ScrollView(.horizontal) {
    HFlow {
        //Flow content
    }
}

Parameters

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

VFlow

A view that arranges its children in a vertical flow.

Usage

ScrollView(.vertical) {
    VFlow {
        //Flow content
    }
}

Parameters

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

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...
Swift-picker-views - inline single and multi picker views for UIKit. Without tableview! Easy and simple
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

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

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

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

Apple provides us two ways to use UIKit views in SwiftUI

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

Comments
  • Fails to revert to portrait

    Fails to revert to portrait "arrangement" when device (or simulator) is reoriented to portrait.

    The view correctly "rearranges" when moving from a device's portrait orientation, but fails to revert when moving the device back from landscape to portrait. The view "sticks" and is wider than the screen.

    This is my code which recreates the above bug. Am I doing something wrong?

    struct ContentView: View {
        
        var words: [String] = [
            "Sed", "perspiciatis", "unde", "omnis", "iste", "natus", "error", "accusantium", "doloremque", "laudantium,", "totam", "rem", "aperiam,", "eaque", "ipsa", "quae", "ab", "illo", "inventore", "veritatis", "et", "quasi", "architecto", "beatae", "vitae", "dicta", "sunt", "explicabo", "Nemo", "enim", "ipsam", "voluptatem", "aspernatur", "odit", "fugit,", "consequuntur", "magni", "eos", "qui", "ratione", "sequi", "nesciunt", "Neque", "porro", "quisquam", "est,", "dolorem", "ipsum", "quia", "dolor", "sit", "amet,", "consectetur,", "adipisci", "velit,", "sed", "non", "numquam", "eius", "modi", "tempora", "incidunt", "labore", "magnam", "aliquam", "quaerat", "ad", "minima", "veniam,", "quis", "nostrum", "exercitationem", "ullam", "corporis", "suscipit", "laboriosam,", "nisi", "ut", "aliquid", "ex", "commodi", "consequatur?", "Quis", "autem", "vel", "iure", "in", "ea", "quam", "nihil", "molestiae", "consequatur", "illum", "eum", "fugiat", "quo", "voluptas", "pariatur", "At", "vero", "accusamus", "iusto", "odio", "dignissimos", "ducimus", "blanditiis", "praesentium", "voluptatum", "deleniti", "atque", "corrupti", "quos", "dolores", "quas", "molestias", "excepturi", "occaecati", "cupiditate", "provident,", "similique", "mollitia", "animi,", "irure", "reprehenderit", "voluptate", "velit", "esse", "cillum", "dolore", "eu", "nulla", "Excepteur", "sint", "occaecat", "cupidatat", "proident", "culpa", "officia", "deserunt", "mollit", "anim", "id", "est", "laborum"
           ]
        
        var body: some View {
            ScrollView (.vertical) {
                VFlow {
                    ForEach (words, id: \.self) { word in
                        Text(word)
                            .padding(.vertical, 2)
                            .padding(.horizontal, 6)
                            .background(Color.mint)
                            .cornerRadius(7.5)
                    }
                }
            }
            .padding(.horizontal)
        }
    } 
    
    
    opened by Rillieux 2
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
๐Ÿฅณ Give birthday celebration message to foster children ๐ŸŽ‚

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

๊ฐœ๋ฐœ์ž์•„์นด๋ฐ๋ฏธ_ํฌ์Šคํ… 4 Jul 29, 2022
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

Gordan Glavaลก 115 Dec 28, 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
A flexible collection view with proper horizontal layout flow

FlexCollection A very simple flexible collection view using SwiftUI that automat

null 1 Dec 29, 2021
Pintrest flow layout UICollectionView

pintrest-flow-layout Pintrest flow layout UICollectionView You need to adjust the coulmns number you need after setting the layout var layout

Anas Almomany 11 Nov 8, 2022
DG Carousel Flow Layout

DGCarouselFlowLayout A carousel flow layout for UICollectionView on iOS. Require

donggyu 7 Aug 6, 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