I'm trying to animate in and out a button in a stack view, when one is pressed. When hiding the camera button, the animation looks fine, but when unhiding it slides in from the left which looks odd.
Code below:
@IBAction func scanButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.3) { [self] in
if cameraButton.alpha == 0{
cameraButton.alpha = 1
}else{
cameraButton.alpha = 0
}
}
UIView.animate(withDuration: 0.3) { [self] in
cameraButton.isHidden.toggle()
}
}
I've tried to fix it by using constraints instead of a stack but to no avail. If anyone could help it would be much appreciated. (Please ignore how awful the if/else statement is)