I added an UIView
with some animation by using the following code:
CGRect a = CGRectMake(10,10,295,460);
UIView *customView = [[UIView alloc]initWithFrame:a];
customView.tag=10;
[self.tableView addSubview:customView];
[UIView animateWithDuration:1.0
animations:
^{
customView.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
}
];
When I try to remove the UIView
with animation, the animation seems not working. The view is just getting removed without any animation.
Here is what I have to remove the UIView
with animation:
UIView *removeView=[self.tableView viewWithTag:10] ;
removeView .transform = CGAffineTransformMakeScale(1.0f, 1.0f);
[removeView removeFromSuperview];
[UIView animateWithDuration:1.5
animations:
^{
removeView .transform = CGAffineTransformMakeScale(0.0f, 0.0f);
}
];
I tried by placing the [UIView animateWithDuration:1.5 ...
block before and after the [removeView removeFromSuperview]
, but none gave me the animation. Kindly help me out in this.
[UIView animateWithDuration:1.5 animations:^ {
removeView.transform = CGAffineTransformMakeScale(0.0f, 0.0f);
} completion:^(BOOL finished) {
[removeView removeFromSuperview];
}];
Some changes:
UIView *removeView=[self.tableView viewWithTag:10] ;
removeView .transform = CGAffineTransformMakeScale(1.0f, 1.0f);
[removeView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1.5];
[UIView animateWithDuration:1.5
animations:
^{
removeView .transform = CGAffineTransformMakeScale(0.01f, 0.01f);
}
];
Try setting your final transform to something small but nonzero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With