How to align baselines of text in UILabels with different font sizes on iOS?

前端 未结 5 1875
野性不改
野性不改 2021-01-04 01:13

I need to align the baselines of text in UILabels. What I\'m currently doing is I\'m aligning the baselines of UILabels containing the text, and when the text font size in t

5条回答
  •  遥遥无期
    2021-01-04 01:50

    After iOS9. With autolayout, UILabel has an anchor called: lastBaselineAnchor. For example:

    hintLabel.lastBaselineAnchor.constraint(equalTo: titleLabel.lastBaselineAnchor).isActive = true
    

提交回复
热议问题