STULabel icon indicating copy to clipboard operation
STULabel copied to clipboard

setText bug, unable to update text to blank

Open vanesca88 opened this issue 2 years ago • 0 comments

Wonder library for sure :)

I've been bumping into an issue since day one with STULabel. Seems you can't set a label with a text (like: "abc") And then update with a blank text (like: " ") or ("") or even multiple spaces But the text simply won't update.

My work-around, after trying so many different options: Create your own update function of STULabel, in an extension. And then call that function, everytime you want to update a text. What it does: it makes the text invisible, when-ever it is empty, and visible, when it has a text.

extension STULabel {

public func update(_ text: String) { // fix: empty text doesn't update field!
    self.text = text
    self.isHidden = text.isEmpty // <- fix 
}

}

Hope this helps someone, who's still using this amazing library. This is of course a temporary fix, but it works really good.

vanesca88 avatar Nov 19 '21 02:11 vanesca88