Marko Zadravec Marko Zadravec - 1 month ago 14
iOS Question

NSLabel Autoshrink with top constraints

I try to figure out autoshrink option in UILabel with regarding top constraint.

I have UIView and three labels. One of them has autoshrink option on. It has constraint to be centered, and has Trailing and Top constraint which should shrink label when changing size of UIView. If I make UIVIew thinner, font size is decreased, but if I change height of UIView font is not changed.

Constraints on UILabels :


  • Align Center X to Superview

  • Align Center Y to Superview

  • Trailing Space to Superview >= 50

  • Top Space to Superview >= 40

  • Align Center X to label2

  • Top Space to label1 equals :15

  • Bottom space to label2 equals :3



Label 1 constraints :


  • Align Center x to superview

  • Trailing Space to superview >=10

  • Leading Space to superview >=10

  • Bottom Space to Shrink Label equal 15



Label 2 constraint :


  • Align Center X to Shrink label

  • Top Space to Shrink label equals 3



How to change this?

What I want is, on last image that label will be nice autoshrink. So if I change width or height of the UIView label should shrink.

Normal size

Width change

Height change

Answer

plz select your Shrink label set

Number of lines is 0

Line Breaks: Clip

Autoshrink: Minimum Font Scale 0.25 enter image description here

Comments