A lightweight SwiftUI ViewModifier that detects whether the device is in a partially folded state — specifically tracking the active fold division reserved region introduced in iOS 27.1.
Built on top of Apple's reservedRegions(kind:options:layoutDirectionBehavior:) API.
On iPhone Duo, the system exposes reserved regions where the physical fold divides the display. ActiveFoldDivisionReader gives you a simple Bool binding that tells you whether such a fold division is currently active — so you can adapt your layout accordingly.
On older OS versions (< iOS 27.1), it gracefully falls back and sets the binding to false.
1. Copy Sources/ActiveFoldDivisionReader.swift into your Xcode project.
2. Use the .activeFoldDivisionReader(hasActiveDivision:) modifier on any view:
import SwiftUI
struct ContentView: View {
@State private var isFolded = false
var body: some View {
HStack {
SidebarView()
if !isFolded {
DetailView()
}
}
.activeFoldDivisionReader(hasActiveDivision: $isFolded)
}
}When isFolded becomes true, the device has an active fold division and you can rearrange your UI — hide panels, swap layouts, show a compact mode, etc.
struct AdaptiveView: View {
@State private var hasActiveDivision = false
var body: some View {
Group {
if hasActiveDivision {
// Fold is active — show each pane on its own side
HStack(spacing: 0) {
LeftPane()
RightPane()
}
} else {
// No fold — standard layout
NavigationSplitView {
LeftPane()
} detail: {
RightPane()
}
}
}
.activeFoldDivisionReader(hasActiveDivision: $hasActiveDivision)
}
}- iOS 27.1+ for fold detection (gracefully degrades on earlier versions)
- Swift 6.2+
- Xcode 27+
This is a single-file utility — just drag and drop.
- Download or clone this repository
- Copy
Sources/ActiveFoldDivisionReader.swiftinto your Xcode project - Make sure the file is added to your target
This project is licensed under the MIT License — see the LICENSE file for details.
You are free to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of this software. Contributions, forks, and pull requests are very welcome.
Contributions are welcome! Feel free to:
- Open an issue for bugs or feature requests
- Submit a pull request
- Fork and build on top of it
- GitHub: @mohammadgdz
If you have questions, suggestions, or just want to say hi — open an issue or reach out.