Set the split size of ArrangementView with splitArrangementLayoutRatio

⋅ 2 min read ⋅ iOS SwiftUI

Table of Contents

When ArrangementView splits two views, each one gets half of the screen by default.

If you want one view to be smaller, like a cover next to an article, iOS 27.1 adds a modifier for that: splitArrangementLayoutRatio.

How to use splitArrangementLayoutRatio

Apply it to one of the views inside ArrangementView. The ratio is that view's share of the screen, from 0 to 1.

ArrangementView {
FirstView()
.splitArrangementLayoutRatio(idealHorizontal: 1 / 3)
} secondary: {
SecondaryView()
}

idealHorizontal is for when the views sit side by side. Here, First View takes a third of the width and Secondary View takes the rest.

An open iPhone Duo with First View and Secondary View side by side. Without a ratio they are 433 points wide each. With idealHorizontal 1/3, First View is 288 points and Secondary View is 578 points.
Open iPhone Duo. Without a ratio, both views are 433 points wide. With idealHorizontal: 1 / 3, First View is 288 and Secondary View is 578.

You can put the modifier on either view. Put it on the secondary view, and the secondary view gets that share instead.

You can easily support sarunw.com by checking out this sponsor.

Sponsor sarunw.com and reach thousands of iOS developers.

Stacked views

When the screen is taller than it is wide, ArrangementView stacks the views instead. For that, use idealVertical.

FirstView()
.splitArrangementLayoutRatio(idealVertical: 1 / 3)
A folded iPhone Duo with First View stacked above Secondary View. Without a ratio both are 322 points tall. With idealVertical 1/3, First View is 214 points and Secondary View is 429 points.
Folded iPhone Duo. Without a ratio, both views are 322 points tall. With idealVertical: 1 / 3, First View is 214 and Secondary View is 429.

Each value only works on its own axis. idealHorizontal does nothing when the views are stacked, and idealVertical does nothing when they are side by side.

One value for both

If you want the same ratio either way, pass a single value.

FirstView()
.splitArrangementLayoutRatio(1 / 3)

It gave 288 points wide when open and 214 points tall when folded, the same as idealHorizontal and idealVertical at 1/3.

The fold comes first

On a half-open iPhone Duo, the split always sits on the fold. The ratio is ignored.

With or without a ratio, the two views were 455 and 371 points wide, one on each side of the hinge.

They aren't equal because of the status bar, not the split.

A half-open iPhone Duo. The hinge is in the middle, so each half of the display is 475 points. First View fills the left half up to the hinge at 455 points. The status bar takes 84 points on the right edge, so Secondary View is 371 points.
Each half of the display is the same size. The status bar takes 84 points from the trailing side, so Secondary View is smaller.

You can easily support sarunw.com by checking out this sponsor.

Sponsor sarunw.com and reach thousands of iOS developers.

Things to know

  • It's iOS 27.1. splitArrangementLayoutRatio, and ArrangementView itself, need iOS 27.1.
  • The view doesn't grow to fit. If the content needs more space than the ratio gives, it spills out of its area. Pick a ratio that leaves enough room for your content.
  • There's more than an ideal value. The full version also takes a minimum and a maximum for each axis: minHorizontal, idealHorizontal, maxHorizontal, and the same for vertical. If you want a size in points instead of a ratio, there's splitArrangementLayoutSize(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:).

Read more article about iOS, SwiftUI, or see all available topic

Enjoy the read?

If you enjoy this article, you can subscribe to the weekly newsletter.
Every Friday, you'll get a quick recap of all articles and tips posted on this site. No strings attached. Unsubscribe anytime.

Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.

I also make short videos and visual guides on Patreon. Some things are easier to see than to read, like how an API looks and moves on a real screen. If you like to learn that way, come and watch. Sharing the article is also greatly appreciated.

Become a patron Tweet Share
Previous
Size classes on iPhone Duo

The horizontal and vertical size classes, and the display size in points, for every iPhone Duo pose and orientation.

← Home