Understanding “firstBaseLine” vs. “baseLine” AutoLayout Constraint

前端 未结 2 1757
抹茶落季
抹茶落季 2021-02-18 23:35

I\'ve created the following view that looks as follow:

And used Add missing constraints t automatically add constraints. I am pretty new in iOS

2条回答
  •  星月不相逢
    2021-02-18 23:40

    From the Apple Docs:

    NSLayoutAttributeBaseline
    The object’s baseline.
    Available in iOS 6.0 and later.
    NSLayoutAttributeFirstBaseline
    The object’s baseline. For objects with more than one line of text, this is the baseline for the topmost line of text.
    Available in iOS 8.0 and later.

    Here is also a screenshot of the difference when aligning to a three line label. The upper green label is using NSLayoutAttributeFirstBaseline and the lower green label is using NSLayoutAttributeBaseline. These are the only constraints on the two green labels besides they are both Horizontally pinned 40 from the Pink Label

提交回复
热议问题