Value of type UILabel has no member constant

Hi


Below is the code

@IBAction func btnAction(_ sender: UIButton) {
        if isLabelAtMaxHeight {
            btn.setTitle("Read more", for: .normal)
            isLabelAtMaxHeight = false
            lblHeight.constant = 70
        }
        else {
            btn.setTitle("Read less", for: .normal)
            isLabelAtMaxHeight = true
            lblHeight.constant = getLabelHeight(text: "asaSAsas aasadsadsadasd dsadsdasdasdasdasdasdasdasdasdasdasdasdd sdsadasdasdsadasdasdasdasdsd sadsadsadsadasdasdasdasdasd sdsadsadasdasdasdasdd sadsadassdadsadsadsadsadsadsa dssaddsdsadsdsdsdsdsadsads sdadsdsadsadsadsadsdsadsadsa saddssdadsadsa", width: view.bounds.width)
        }
    }

please take time to be precise on the problem you have.


What is lblHeight ? It is defined nowhere.

are you sure you want to set the constant of a UILabel or of a constraint on UILabel ?


on which line do you get the error ? Both 5 and 9 ?

Hi


On these lines . I want to implement Read More/ Read Less functionality. I am trying from this link

https://stackoverflow.com/questions/42338768/read-more-less-with-swift-3


lblHeight.constant = 70

lblHeight.constant = getLabelHeight(text: "adsa", width: view.bounds.width)


I have defined Outlet lblHeight


Thanks

As Claude has already hinted at it sounds like you're expecting lblHeight to be a NSLayoutConstraint (which is the case in the StackOverflow code) - from the error message that is only supplied in the title of this question it sounds like you have defined it as a UILabel

you should have :

@IBOutlet weak var lblHeight: NSLayoutConstraint!

Most likely you've defined it as UILabel!


Once again, if you want help from this forum, be precise in your requests and provide the information that is needed.

Value of type UILabel has no member constant
 
 
Q