2

I have a UILabel in a custom button.

to the left of the label I have a UIPageControl. The PageControl might have more or less pages. Now I would like to use auto layout to hide the label when there is not enough room for all three of them. When just changing the width of the label the text gets truncated or clipped. Is there some trick?

UIPageControl UILabel UIButton

343max
  • 400
  • 1
  • 12

2 Answers2

1

You're correct in setting the width or height layout constraint (don't set the frame directly), so other subviews are laid out properly - but in addition you, you should set its hidden property to YES

And don't remove subviews - as any other constraints that depend on them will be broken.

Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
0

You could override layoutSubViews on your view and programatically remove the label when there is not enough room. I don't think auto layout will do it.

Kenny
  • 1,083
  • 2
  • 8
  • 23