'Selecting the name of a UIButton swift5

I have a UIButton called picPressed, this UIButton has a background image. I want to to be able to get the name of the buttons background image. I am trying something like:

let hello = picPressed.backgroundImage.name()
Print(hello)

But get an error saying:

value of type '(UIControl.State) -> UIImage?' has no member 'name'

How can isolate this attribute in swift5?



Solution 1:[1]

No, buttons don't remember their names (or the name of the image you install into them.)

I suggest you create an object that manages a button, takes a filename for an image, and remembers that filename for later. (Alternately you could subclass UIButton, but that can get complex.)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Duncan C