UIArrangementViewController Split Ratio

How can we do this in UIKit using UIArrangementViewController? I can’t find an equivalent to splitArrangementLayoutRatio.

I did find UISplitArrangement.Dimension.fractional(CGFloat), but I can’t find a way to apply it to UIArrangementViewController, and I’m not even sure whether .fractional is intended for this purpose.

ArrangementView { ConversationView() .splitArrangementLayoutRatio(0.3) } secondary: { PhotosView() } .arrangementViewStyle(.split.axes(.horizontal))

Answered by Technology Evangelist in 906683022

The pattern is like some of the other UIKit configuration-based APIs, where you ask for a default configuration or set of properties, then mutate those and pass them back:

    let result = UIArrangementViewController(nibName: nil, bundle: nil)

    var arrangement: UISplitArrangement = .split.axes(.horizontal)
    var properties = arrangement.defaultViewProperties
    properties.width.preferred = .fractional(0.33)
    arrangement.setViewProperties(properties, for: .primary)
    result.updateArrangement(arrangement)

    return result

Accepted Answer

The pattern is like some of the other UIKit configuration-based APIs, where you ask for a default configuration or set of properties, then mutate those and pass them back:

    let result = UIArrangementViewController(nibName: nil, bundle: nil)

    var arrangement: UISplitArrangement = .split.axes(.horizontal)
    var properties = arrangement.defaultViewProperties
    properties.width.preferred = .fractional(0.33)
    arrangement.setViewProperties(properties, for: .primary)
    result.updateArrangement(arrangement)

    return result

UIArrangementViewController Split Ratio
 
 
Q