Understanding “firstBaseLine” vs. “baseLine” AutoLayout Constraint

前端 未结 2 1747
抹茶落季
抹茶落季 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:51

    I don't recommend ever using "Add Missing Constraints." It is a very unpredictable wizard that DWIW (does what it wants). Learn each constraint and add it by hand. Ctrl-drag between objects in the scene hierarchy; use the constraints inspector and edit numeric values; use 'Update Frames' from the triangle pop-up; delete constraints from the inspector; repeat until you get it.

    firstBaseLine refers to the top baseline of a multi-line object: Storyboard warning : First baseline layout attribute before iOS 8.0

    if the label or text field involved only has one line, it's a useless constraint.

    When you want two side-by-side one-line blotches of text to align vertically, even though their font sizes, ascenders, and baseline descenders may differ, use baseLine alignment. It will look natural like the strings are on the same line.

    Bottom, Top, and Center vertical alignments are also possible and more appropriate for non-text objects.

提交回复
热议问题