Ios 如何使用动画删除uiview
我使用以下代码添加了一个带有一些动画的Ios 如何使用动画删除uiview,ios,objective-c,animation,uiview,Ios,Objective C,Animation,Uiview,我使用以下代码添加了一个带有一些动画的UIView: 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: ^{ c
UIView
:
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);
}
];
当我尝试用动画删除ui视图
时,动画似乎不起作用。视图刚刚被删除,没有任何动画
以下是我必须用动画删除的ui视图
:
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);
}
];
我尝试将
[UIView animateWithDuration:1.5…
块放在[removeView removeFromSuperview]
之前和之后,但没有人给我动画。请帮我解决这个问题。尝试在动画结束之前删除视图:
[UIView animateWithDuration:1.5 animations:^ {
removeView.transform = CGAffineTransformMakeScale(0.0f, 0.0f);
} completion:^(BOOL finished) {
[removeView removeFromSuperview];
}];
[removeView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:2.0];
一些变化:
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);
}
];
尝试将最终变换设置为较小但不为零的值。试试这个,它对我有用:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5f];
removeView.transform = CGAffineTransformMakeTranslation(removeView.frame.origin.x,1000.0f + (removeView.frame.size.height/2));
aview.alpha = 0;
[UIView commitAnimations];
参考苹果公司的以下样本
[UIView transitionWithView:containerView
duration:0.2
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{ [fromView removeFromSuperview]; [containerView addSubview:toView]; }
completion:NULL];
上面的代码为指定的容器视图创建了翻转转换。在转换的适当位置,一个子视图被删除,另一个子视图被添加到容器视图中。这使它看起来像是一个新视图被新的子视图翻转到位,但实际上它只是一个相同的视图,用一个新的configu动画返回到位配给
可能是需要管理的动画类型
参考:-
是否删除了其他调用
[removeView removeFromSuperview]
?我将上述代码放在一个方法中,并尝试通过单击按钮调用该方法。我尝试了此操作。但没有动画!!!缩放因子应该有问题!!不知为什么我没有正确设置它。