First Baseline and Last Baseline Properties in UIStackView
Asked Answered
A

2

18

What effect do the First Baseline and Last Baseline properties have on the subviews of a UIStackView?

Generally, can someone please illustrate the implementation of these values?

Ada answered 26/11, 2015 at 7:31 Comment(0)
G
40

Suppose you have a two-line text view (or field or label or button) and a three-line text view, and you add them to a horizontal stack view. Do you want to align their first lines, or their last lines? That's the difference.

.FirstBaseline:

.FirstBaseline

.LastBaseline:

.LastBaseline

Note: I increased the vertical content hugging and compression resistance priorities to 1000 (required) to get this to work properly.

Gony answered 26/11, 2015 at 9:2 Comment(1)
I added a UILabel and a UITextView and applied First Baseline, but their first lines are not aligned.Ada
A
0
var firstBaselineAnchor: NSLayoutYAxisAnchor

Represents the baseline for the topmost line of text in the view.

var lastBaselineAnchor: NSLayoutYAxisAnchor

Represents the baseline for the bottommost line of text in the view.

Amaral answered 28/1, 2023 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.