ElaWorkshop / TagListView

Simple and highly customizable iOS tag list view, in Swift.
MIT License
2.63k stars 492 forks source link

Enabling Remove Button later after setting it to false #283

Open CharlieOxendine opened 3 years ago

CharlieOxendine commented 3 years ago

If you try and use a button to trigger enabling the remove button it will show the extra space for a remove icon, but the icon will be invisible. A work around for this is by calling

interestsTagView.enableRemoveButton = true

in the ViewDidLoad and then, in ViewDidAppear, call

interestsTagView.enableRemoveButton = false

PaulDowney commented 3 years ago

I got the same problem

mlichwa commented 2 years ago

Looks to me that draw is not called when buttons are initially disabled. One workaround would be to remove the body of the draw function from the CloseButton() completely and instead use something similar to: self.removeButton.setImage(UIImage(systemName: "trash"), for: .normal) to draw a trash icon. You can add that line in the TagView class inside of a public init(title: String) function.

Here is how my public init(title: String) looks:

public init(title: String) { super.init(frame: CGRect.zero) setTitle(title, for: UIControl.State()) setupView() self.removeButton.setImage(UIImage(systemName: "trash"), for: .normal) }