optonaut/ActiveLabel.swift

Hide ActiveLabel with NSLayoutConstraint

LebonNic opened this issue · 1 comments

Hi!

First of all thank for this great pod! However, in my app I have a scenario where an ActiveLabel should be hidden dynamically. To do so, I set the text of the label to nil and I set its height to 0 through an attached NSLayoutConstraint. However, the ActiveLabel is still visible in the UI (as you can see in the first screen shot).

Simulator Screen Shot - iPhone 8 - 2020-09-14 at 17 26 18

If I remove "ActiveLabel" from the custom class (in the interface builder) it works as expected:

Simulator Screen Shot - iPhone 8 - 2020-09-14 at 17 32 09

It is normal? Is there a specific way to achieve this?

Best regards,
Nicolas

This pull request #367 will fix the issue. While waiting for the pod update to be released, you can add manually these lines in the property intrinsicContentSize of the ActiveLabel class:

guard let text = text, !text.isEmpty else {
            return .zero
        }

Clean your project, rebuild and it will work!