i want to make a slide animation when a button tapped. But it acts really weird. here my codes are.
the if blocks work normal but in the else block the UIButton doesnt stop. First it goes to 0 point and then starts to slide right side. I mean its x position increase. But i want it to stop in the point 0. So how can i achieve it ? what is the wrong in these code ?
Code:
- (IBAction)showHideView:(UIButton *)sender
{
if (self.isViewVisible)
{
[UIView animateWithDuration:0.5 animations:^{
self.btnKulak.frame = CGRectMake(296, 205, 24, 62);
[self.btnKulak setBackgroundImage:[UIImage imageNamed:@"kapaliKulak.png"] forState:UIControlStateNormal];
} completion:^(BOOL finished) {
self.isViewVisible = NO;
}];
}
else
{
[UIView animateWithDuration:7.5 animations:^{
self.btnKulak.frame = CGRectMake(0, 205, 24, 62);
[self.btnKulak setBackgroundImage:[UIImage imageNamed:@"acikKulak.png"] forState:UIControlStateNormal];
} completion:^(BOOL finished) {
self.isViewVisible = YES;
}];
}
}