AamirR
AamirR

Reputation: 12218

Autolayout - UILabel shrinks in width after orientation change, cause by another UILabel which is supposed to auto-adjust font size

I have 2 UILabel side-by-side horizontally using auto-layout as following:

  1. 1st-Label is full-width (like sizeToFit)
  2. 2nd-Label has adjustsFontSizeToFitWidth = true

enter image description here

On launch everything is fine, when returning from landscape to portrait 1st-Label shrinks to zero width.

Constraints are following:

Upvotes: 0

Views: 51

Answers (2)

AamirR
AamirR

Reputation: 12218

I missed to set ContentCompressionResistancePriority on 2nd-Label:

secondLabel.setContentCompressionResistancePriority(.defaultLow, for:.horizontal)

Upvotes: 0

Shehata Gamal
Shehata Gamal

Reputation: 100541

set compression resistance priority of label 1 to 1000

Upvotes: 1

Related Questions