Hi all I am facing an strange issue . I want to increase the width of a view on click of a button with animation which is working fine in my case. The code I am using to increase the width is below-
@IBAction func increaseWidth(_ sender: AnyObject) {
UIView.animate(withDuration: 1.0, delay: 0, options:
[.allowUserInteraction], animations: {
print("Animation function animateStuff() started!")
let frmPlay : CGRect = self.nameLbl.frame
let originXbutton = frmPlay.origin.x
let originYbutton = frmPlay.origin.y
let originWidthbutton = frmPlay.size.width
let originHeightbutton = frmPlay.size.height
self.nameLbl.frame = CGRect(origin: CGPoint(x: originXbutton,y :originYbutton), size: CGSize(width: originWidthbutton+100, height: originHeightbutton))
}, completion: { finished in
})
}
But the code which is use by me not decreasing the width with animation.It is just decreasing the width.The code which is used by to decrease the width is below-
@IBAction func decreaseWidth(_ sender: AnyObject) {
UIView.animate(withDuration: 1.0, delay: 0, options:
[.allowUserInteraction], animations: {
print("Animation function animateStuff() started!")
let frmPlay : CGRect = self.nameLbl.frame
let originXbutton = frmPlay.origin.x
let originYbutton = frmPlay.origin.y
let originWidthbutton = frmPlay.size.width
let originHeightbutton = frmPlay.size.height
// self.nameLbl.frame = frmPlay
self.nameLbl.frame = CGRect(origin: CGPoint(x: originXbutton,y :originYbutton), size: CGSize(width: originWidthbutton-100, height: originHeightbutton))
}, completion: { finished in
})
}
Please help where I am going wrong.