How to check if a button has this image

Viewed 4419


I want to check if myButton has a named image.

I try this but it doesn't work

if (myButton.currentImage?.isEqual(UIImage(named: "ButtonAppuyer.png")) != nil){
        print("YES")
    } else {
        print("NO")
    }

and this too doesn't work

if myButton.currentImage?.isEqual(UIImage(named: "ButtonAppuyer.png")){
        print("YES")
    } else {
        print("NO")
    }
6 Answers

in swift 4.2 and Xcode 10.1

buttonOne.image(for: .normal)!.pngData() == UIImage(named: "selected")!.pngData()
if myCell.followButton.currentImage.isEqual(UIImage(named: "yourImageName")) {
    //do something here
}
Related