uikit – UISplitViewController format distinction between iOS 17 and iOS 18


I’ve a easy UISplitViewController format of at all times seen major and secondary columns.

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, choices connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = (scene as? UIWindowScene) else { return }

        // Create a UISplitViewController
        let splitViewController = UISplitViewController(type: .doubleColumn)
        splitViewController.preferredDisplayMode = .oneBesideSecondary
        splitViewController.presentsWithGesture = false

        // Arrange major and secondary view controllers
        let primaryVC = UIViewController()
        primaryVC.view.backgroundColor = .systemBlue
        let secondaryVC = UIViewController()
        secondaryVC.view.backgroundColor = .systemGreen

        // Assign them to the break up view controller
        splitViewController.setViewController(primaryVC, for: .major)
        splitViewController.setViewController(secondaryVC, for: .secondary)

        // Set most well-liked width and min/max column width
        splitViewController.preferredPrimaryColumnWidth = 80
        splitViewController.minimumPrimaryColumnWidth = 80
        splitViewController.maximumPrimaryColumnWidth = 80

        // Initialize the window
        window = UIWindow(windowScene: windowScene)
        window?.rootViewController = splitViewController
        window?.makeKeyAndVisible()
    }

It labored succesfully like that for my app for a while. Nevertheless, I’ve seen some layouting points on iOS18 and began to dig a bit deeper. It seems that one thing modified in UISplitViewController’s construction between releases.

I am working the follwing debuger command:

po splitViewController?.view.subviews.first?.subviews

On iPadOS 18:

; layer = >
; layer = >
>

On iPadOS 17.5:

; layer = >
; layer = >
; layer = >

In each circumstances we have now 2 tab containers and a divider. Nevertheless, on iOS 18 it seems that the divider is positioned not by aspect however reasonably above the container view.

When attaching a view to the view.leadingAnchor or view.safeAreaLayoutGuide.leadingAnchor of secondary view controller

on iPadOS 18 it goes behind the divider:

iOS 18 behaviour

on iPadOS 17 it goes subsequent to the divider:

iOS 17 behaviour

Now, my query is, assuming that is not an Apple bug – is there option to get this 0.5px dimension of the divider in any elegant means? It does not appear to be mirrored by secure space values or something related.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles