Ios 使用动画显示和隐藏UITableView
我试图用动画“从左到右和从右到左的过渡”来显示和隐藏一个tableView 这是我已经厌倦的,但在CGRectMake中使用随机值后 有人能帮我修一下吗Ios 使用动画显示和隐藏UITableView,ios,objective-c,xcode,uitableview,animation,Ios,Objective C,Xcode,Uitableview,Animation,我试图用动画“从左到右和从右到左的过渡”来显示和隐藏一个tableView 这是我已经厌倦的,但在CGRectMake中使用随机值后 有人能帮我修一下吗 -(void)Display:(UITableView *)tableView :(UIView *)view{ tableView.alpha=1; [UIView animateWithDuration:0.35 animations:^{
-(void)Display:(UITableView *)tableView :(UIView *)view{
tableView.alpha=1;
[UIView animateWithDuration:0.35
animations:^{
tableView.frame = CGRectMake(-209, 440, 180, 209);
}
completion:^(BOOL finished){
[tableView setHidden:YES];
}
];
}
-(void)Hide:(UITableView *)tableView :(UIView *)view :(int )tb{
tableView.alpha=1;
[tableView setHidden:NO];
[UIView animateWithDuration:.45
animations:^{
tableView.frame = CGRectMake(3, 442, 180, 209);
}
];
}
您可以使用以下代码:
[UIView transitionFromView:firstView
toView:secondView//table view
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:^(BOOL finished) {
[firstView.superView addSubview:secondView];
[firstView.superView sendSubviewToBack:firstView];
}];
如果您想要像Facebook这样的动画,请使用:-ECSlidingViewController 或
如果您想要正常动画,请设置帧,并将alpha从1.0减少到0.0,持续时间不变。从您的问题很难判断,只能通过“从左到右和从右到左的过渡” 你想要这样的东西吗 用于设置左侧的动画
[UIView animateWithDuration:1.0f
delay:0.0f
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
animations:^{
self.tableView.frame = CGRectMake(0.0f, -self.tableView.frame.size.width, self.tableView.frame.size.width, self.tableView.frame.size.height);
}
completion:NULL];
用于设置右侧的动画
[UIView animateWithDuration:1.0f
delay:0.0f
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
animations:^{
self.tableView.frame = CGRectMake(0.0f, self.view.bounds.size.width, self.tableView.frame.size.width, self.tableView.frame.size.height);
}
completion:NULL];
用于在中设置动画
[UIView animateWithDuration:1.0f
delay:0.0f
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
animations:^{
self.tableView.frame = CGRectMake(0.0f, 0.0f, self.tableView.frame.size.width, self.tableView.frame.size.height);
}
completion:NULL];
您可以将表格重新加载等放在完成块中吗?然后重新设置tableView的动画?请给我们看一下您已经尝试过的内容。@Dave,这是我想做的already@fourthnovember你说它在上面的帖子里起作用。你的问题是什么?mityaika07谢谢,我尝试了你的解决方案,但对所有视图都有效,不仅仅是我的具有翻转的tableview,而不是幻灯片转换的左右视图,我尝试了这个2方法,它有效,但我迷路了CGRectMake,也许有更好的方法使用它设置从左到右的转换?没有随机设置CGRectMakeMake谢谢但这不是我想要做的我只是想用animationok显示和隐藏一个uitableView,然后使用它可能很有用:-最初设置tableview的帧(0,0,0460),然后在动画部分(0,0320460)-(void)animateView:(UIView*)视图位置:(CGPoint位置{[UIView beginAnimations:nil context:NULL];[UIView setAnimationDuration:2];//将中心设置为最终位置//将变换设置回标识,从而撤消以前的缩放效果。theView.frame=CGRectMake(0,0320460);theView.transform=cGrafineTransformity;[UIView commitAnimations];}请你解释一下CGRectMake中的第一个点的值,它们在我们的示例中效果很好,但我只需将结束点设置为不在左上角视图的末尾。为了进行效果幻灯片放映和隐藏,所以CGRectMake的顺序是origin.X,origin.Y,width,height…所以移动视图(在本例中为tableview)向右……我们增加原点。如果我们想向左移动它,我们减少。