ios - UI Button doesnt perform action till 2nd time you press -


i have button on uitabbar (custom) , animations when button clicked doesn't perform until press twice. print statement used print's on first try though i'm not sure why doesn't perform animations on first try. here code:

func menubuttonaction(sender: uibutton) {     if sender.currentimage == #imageliteral(resourcename: "play") {         uiview.animate(withduration: 0.3, animations: {              sender.setimage(#imageliteral(resourcename: "playbutton2"), for: .normal)             self.button2.frame = cgrect(x: self.tabbar.center.x, y: self.tabbar.center.y - 100,  width: self.buttonimage.size.width, height: self.buttonimage.size.height)             self.view3.alpha = 0.6         })     } else {         sender.setimage(#imageliteral(resourcename: "play"), for: .normal)         uiview.animate(withduration: 0.3, animations: {              self.button2.center = self.button.center             self.view3.alpha = 0         })     }      print("middle button pressed!") } 

i running function through target in viewwillappear:

button.addtarget(self, action: #selector(self.menubuttonaction(sender:)), for: .touchupinside) 

it seems have not set image on button in xib set image in view did load

hope work

button.setimage(#imageliteral(resourcename: "play"), for: .normal) 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -