BlueprintView
@MainActor
public final class BlueprintView : UIView
A view that is responsible for displaying an Element hierarchy.
A view controller that renders content via Blueprint might look something like this:
final class HelloWorldViewController: UIViewController {
private var blueprintView = BlueprintView(element: nil)
override func viewDidLoad() {
super.viewDidLoad()
let rootElement = Label(text: "Hello, world!")
blueprintView.element = rootElement
view.addSubview(blueprintView)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
blueprintView.frame = view.bounds
}
}
-
A base environment used when laying out and rendering the element tree.
Some keys will be overridden with the traits from the view itself. Eg,
windowSize,safeAreaInsets, etc.If this blueprint view is within another blueprint view, the environment of the parent view will be inherited by this view if
automaticallyInheritsEnvironmentFromContainingBlueprintViewsis enabled. In the case of matching keys in both the inherited environment and the provided environment, the values from this environment will take priority over the inherited environment.Declaration
Swift
@MainActor public var environment: Environment { get set } -
If
true, then Blueprint will automatically inherit theEnvironmentfrom the nearest parentBlueprintViewin the view hierarchy.If
false, then only the values fromenvironmentwill be used to seed the environment passed to the element hierarchy.This property is recursive – if the nearest parent
BlueprintViewalso sets this property to true, then you will inherit theEnvironmentfrom that view’s parentBlueprintView, and so on.Defaults to
true.Declaration
Swift
@MainActor public var automaticallyInheritsEnvironmentFromContainingBlueprintViews: Bool { get set } -
The root element that is displayed within the view.
Declaration
Swift
@MainActor public var element: Element? { get set } -
We need to invalidateIntrinsicContentSize when
bound.sizechanges for Auto Layout to work correctly.Declaration
Swift
@MainActor public override var bounds: CGRect { get set } -
An optional explicit layout mode for this view. If
nil, this view will inherit the layout mode of its nearest ancestor or usedefaultif it has no ancestor.Declaration
Swift
@MainActor public var layoutMode: LayoutMode? { get set } -
An optional name to help identify this view
Declaration
Swift
@MainActor public var name: String? -
Provides performance metrics about the duration of layouts, updates, etc.
Declaration
Swift
@MainActor public weak var metricsDelegate: BlueprintViewMetricsDelegate? -
Defaults to
false. If enabled, Blueprint will pass through any touches not recieved by an element to the view hierarchy behind theBlueprintView.Declaration
Swift
@MainActor public var passThroughTouches: Bool { get set } -
Instantiates a view with the given element
Declaration
Swift
@MainActor public required init(element: Element?, environment: Environment = .empty)Parameters
elementThe root element that will be displayed in the view.
environmentA base environment to render elements with. Defaults to
.empty. -
Declaration
Swift
@MainActor public convenience override init(frame: CGRect) -
Measures the size needed to display the view within the given constraining size, by measuring the current
elementof theBlueprintView.If you would like to not constrain the measurement in a given axis, pass
0.0or.greatestFiniteMagnitudefor that axis, eg:// Measures with a width of 100, and no height constraint. blueprintView.sizeThatFits(CGSize(width: 100.0, height: 0.0)) // Measures with a height of 100, and no width constraint. blueprintView.sizeThatFits(CGSize(width: 0.0, height: 100.0)) // Measures unconstrained in both axes. blueprintView.sizeThatFits(.zero)Declaration
Swift
@MainActor public override func sizeThatFits(_ fittingSize: CGSize) -> CGSize -
Measures the size needed to display the view within the given
SizeConstraint. by measuring the currentelementof theBlueprintView.Declaration
Swift
@MainActor public func sizeThatFits(_ constraint: SizeConstraint) -> CGSize -
Measures the size needed to display the view within then given constraining size, by measuring the current
elementof theBlueprintView.If you would like to not constrain the measurement in a given axis, pass
0.0or.greatestFiniteMagnitudefor that axis.Declaration
Swift
@MainActor public override func systemLayoutSizeFitting( _ targetSize: CGSize ) -> CGSize -
Measures the size needed to display the view within then given constraining size, by measuring the current
elementof theBlueprintView.If you would like to not constrain the measurement in a given axis, pass
0.0or.greatestFiniteMagnitudefor that axis.Declaration
Swift
@MainActor public override func systemLayoutSizeFitting( _ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority ) -> CGSize -
For us, this is the same as
sizeThatFits, since blueprint does not contain the same concept of constraints as Autolayout.Declaration
Swift
@MainActor public override var intrinsicContentSize: CGSize { get } -
Declaration
Swift
@MainActor public override var semanticContentAttribute: UISemanticContentAttribute { get set } -
Declaration
Swift
@MainActor public override func safeAreaInsetsDidChange() -
Declaration
Swift
@MainActor public override func layoutSubviews() -
Declaration
Swift
@MainActor public override func didMoveToWindow() -
Ignore any touches on this view and (pass through) by returning nil if the default
hitTestimplementation returns this view.Declaration
Swift
@MainActor public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView?
View on GitHub
BlueprintView Class Reference