mamaral / Neon

A powerful Swift programmatic UI layout framework.
MIT License
4.58k stars 389 forks source link

AutoHeight doesn't work if UILabel text is set after the constraints are made. #53

Closed acrocat closed 7 years ago

acrocat commented 8 years ago

For example, this will only display a label with a height large enough for "Hello World".

        let label : UILabel = UILabel()
        self.view.addSubview(label)

        label.textColor = .black
        label.numberOfLines = 0
        label.lineBreakMode = .byWordWrapping

        label.text = "Hello world"
        label.anchorAndFillEdge(.bottom, xPad: 24, yPad: 24, otherSize: AutoHeight)
        label.text = "asdfn aksdjhf akjsdhf kajhsd fkjhasd fkjhads kjfha sdkjhf akjsdhf akjshdf kajhsdf kjhasd fkh ckhsd chjsdfkv hjsdfv ksjdhfv ksjhdfv kjshdf vkjshdf vkjhsdf end"
mamaral commented 8 years ago

This is correct and intended behavior - setting the label height does not automatically re-layout everything else on the screen. That should be done manually.

acrocat commented 8 years ago

That's fair if it's by design, but I'm migrating from SnapKit where this isn't an issue. From what I understand of AL, if a label doesn't have a constraint for its height, it'll occupy whatever free space it needs.

MontakOleg commented 8 years ago

@acrocat Neon not uses AutoLayout, there is no 'constraints', it just bunch of helpful functions to calculate frames.